csvbase is a simple website for sharing table data. Join the discord.

The weather situation in Manhattan for every hour in 2023.approx. 8,760 rows, last changed 1 month ago

Table of contents

  1. The basics: auth and content negotations
    1. Authentication
    2. Content negotiation
  2. The API: endpoint-by-endpoint
    1. Tables
      1. Reading a table
    2. Rows
      1. Creating a new row
      2. Reading a row
      3. Updating an existing row
      4. Deleting a row

The basics: auth and content negotiation

Authentication

With CSVBase, you authenticate using by putting your username and API key straight in the url (known as "HTTP "basic" auth").

Here's an example:

https://<some_user>:<some_api_key>@csvbase.com/mdfarragher/Manhattan-Hourly-Weather-2023

Basic auth is widely supported and is usually accepted anywhere that accepts urls.

However, mdfarragher/Manhattan-Hourly-Weather-2023 is public so auth is needed only for writes.

Content negotiation

CSVBase APIs use content negotiation to decide what formats are in use. This means it consults HTTP headers to decide what format to send back in response to a request.

It important that you set the Content-Type and Accept headers to be the mimetype you want: typically that is application/json for both. If you fail to include these headers in your requests, the API will still work but CSVBase will pick a sensible default: CSV for tables, JSON for rows.

You can bypass content negotiation for read-only requests by appending a file extension to the url, eg .json. Here's an example of that (same resource as above):

https://<some_user>:<some_api_key>@csvbase.com/mdfarragher/Manhattan-Hourly-Weather-2023.json

This is useful when dealing with software where you aren't able to set headers.

The API: endpoint-by-endpoint

There are three kinds of thing in csvbase:

  1. users
  2. tables
  3. rows

While there's no API for users so far, there is for tables and rows.

Tables

This table looks like this in JSON:

{
    "name": "Manhattan-Hourly-Weather-2023",
    "is_public": true,
    "caption": "The weather situation in Manhattan for every hour in 2023.",
    "licence": null,
    "created": "2024-09-08T13:42:31.637717+01:00",
    "last_changed": "2024-09-08T13:44:34.210387+01:00",
    "columns": [
        {
            "name": "csvbase_row_id",
            "type": "integer"
        },
        {
            "name": "name",
            "type": "string"
        },
        {
            "name": "datetime",
            "type": "string"
        },
        {
            "name": "temp",
            "type": "float"
        },
        {
            "name": "feelslike",
            "type": "float"
        },
        {
            "name": "dew",
            "type": "float"
        },
        {
            "name": "humidity",
            "type": "float"
        },
        {
            "name": "precip",
            "type": "float"
        },
        {
            "name": "precipprob",
            "type": "integer"
        },
        {
            "name": "preciptype",
            "type": "string"
        },
        {
            "name": "snow",
            "type": "float"
        },
        {
            "name": "snowdepth",
            "type": "float"
        },
        {
            "name": "windgust",
            "type": "float"
        },
        {
            "name": "windspeed",
            "type": "float"
        },
        {
            "name": "winddir",
            "type": "integer"
        },
        {
            "name": "sealevelpressure",
            "type": "float"
        },
        {
            "name": "cloudcover",
            "type": "float"
        },
        {
            "name": "visibility",
            "type": "float"
        },
        {
            "name": "solarradiation",
            "type": "integer"
        },
        {
            "name": "solarenergy",
            "type": "float"
        },
        {
            "name": "uvindex",
            "type": "integer"
        },
        {
            "name": "severerisk",
            "type": "integer"
        },
        {
            "name": "conditions",
            "type": "string"
        },
        {
            "name": "icon",
            "type": "string"
        },
        {
            "name": "stations",
            "type": "string"
        }
    ],
    "approx_size": 8760,
    "page": {
        "rows": [
            {
                "row": {
                    "name": "MANHATTAN",
                    "datetime": "2023-01-01T00:00:00",
                    "temp": 12.2,
                    "feelslike": 12.2,
                    "dew": 11.0,
                    "humidity": 92.42,
                    "precip": 0.219,
                    "precipprob": 100,
                    "preciptype": "rain",
                    "snow": 0.0,
                    "snowdepth": 0.0,
                    "windgust": 13.0,
                    "windspeed": 3.0,
                    "winddir": 295,
                    "sealevelpressure": 1007.1,
                    "cloudcover": 100.0,
                    "visibility": 12.3,
                    "solarradiation": 0,
                    "solarenergy": 0.0,
                    "uvindex": 0,
                    "severerisk": 10,
                    "conditions": "Rain, Overcast",
                    "icon": "rain",
                    "stations": "72505394728,KLGA,KNYC,72503014732"
                },
                "row_id": 1,
                "url": "https://csvbase.com/mdfarragher/Manhattan-Hourly-Weather-2023/rows/1"
            }
        ],
        "previous_page_url": null,
        "next_page_url": "https://csvbase.com/mdfarragher/Manhattan-Hourly-Weather-2023?op=gt&n=1"
    }
}

Note that there is the top-level metadata, plus a "page" of rows. Tables are often (usually) too big to be put into a single JSON object so they are "paginated". To follow the table, page by page, you can use the next_page_url and previous_page_url dictionary keys. They will be null if you've reached the end or are at the beginning, respectively.

Reading a table

GET from https://csvbase.com/mdfarragher/Manhattan-Hourly-Weather-2023

You'll need to follow the next_page_url urls (described above) to get to the end of the table.

Rows

Rows from mdfarragher/Manhattan-Hourly-Weather-2023 look like this in JSON:

{
    "row": {
        "name": "MANHATTAN",
        "datetime": "2023-01-01T00:00:00",
        "temp": 12.2,
        "feelslike": 12.2,
        "dew": 11.0,
        "humidity": 92.42,
        "precip": 0.219,
        "precipprob": 100,
        "preciptype": "rain",
        "snow": 0.0,
        "snowdepth": 0.0,
        "windgust": 13.0,
        "windspeed": 3.0,
        "winddir": 295,
        "sealevelpressure": 1007.1,
        "cloudcover": 100.0,
        "visibility": 12.3,
        "solarradiation": 0,
        "solarenergy": 0.0,
        "uvindex": 0,
        "severerisk": 10,
        "conditions": "Rain, Overcast",
        "icon": "rain",
        "stations": "72505394728,KLGA,KNYC,72503014732"
    },
    "row_id": 1,
    "url": "https://csvbase.com/mdfarragher/Manhattan-Hourly-Weather-2023/rows/1"
}

Creating a new row

POST to https://<some_user>:<some_api_key>@csvbase.com/mdfarragher/Manhattan-Hourly-Weather-2023/rows/

Example body
{
    "row": {
        "name": "MANHATTAN",
        "datetime": "2023-01-01T00:00:00",
        "temp": 12.2,
        "feelslike": 12.2,
        "dew": 11.0,
        "humidity": 92.42,
        "precip": 0.219,
        "precipprob": 100,
        "preciptype": "rain",
        "snow": 0.0,
        "snowdepth": 0.0,
        "windgust": 13.0,
        "windspeed": 3.0,
        "winddir": 295,
        "sealevelpressure": 1007.1,
        "cloudcover": 100.0,
        "visibility": 12.3,
        "solarradiation": 0,
        "solarenergy": 0.0,
        "uvindex": 0,
        "severerisk": 10,
        "conditions": "Rain, Overcast",
        "icon": "rain",
        "stations": "72505394728,KLGA,KNYC,72503014732"
    }
}
Example response
{
    "row": {
        "name": "MANHATTAN",
        "datetime": "2023-01-01T00:00:00",
        "temp": 12.2,
        "feelslike": 12.2,
        "dew": 11.0,
        "humidity": 92.42,
        "precip": 0.219,
        "precipprob": 100,
        "preciptype": "rain",
        "snow": 0.0,
        "snowdepth": 0.0,
        "windgust": 13.0,
        "windspeed": 3.0,
        "winddir": 295,
        "sealevelpressure": 1007.1,
        "cloudcover": 100.0,
        "visibility": 12.3,
        "solarradiation": 0,
        "solarenergy": 0.0,
        "uvindex": 0,
        "severerisk": 10,
        "conditions": "Rain, Overcast",
        "icon": "rain",
        "stations": "72505394728,KLGA,KNYC,72503014732"
    },
    "row_id": 1,
    "url": "https://csvbase.com/mdfarragher/Manhattan-Hourly-Weather-2023/rows/1"
}

Status code 201 upon success.

Reading a row

GET from https://csvbase.com/mdfarragher/Manhattan-Hourly-Weather-2023/rows/1

No body is provided with this request. Status code 200 upon success.

Example response
{
    "row": {
        "name": "MANHATTAN",
        "datetime": "2023-01-01T00:00:00",
        "temp": 12.2,
        "feelslike": 12.2,
        "dew": 11.0,
        "humidity": 92.42,
        "precip": 0.219,
        "precipprob": 100,
        "preciptype": "rain",
        "snow": 0.0,
        "snowdepth": 0.0,
        "windgust": 13.0,
        "windspeed": 3.0,
        "winddir": 295,
        "sealevelpressure": 1007.1,
        "cloudcover": 100.0,
        "visibility": 12.3,
        "solarradiation": 0,
        "solarenergy": 0.0,
        "uvindex": 0,
        "severerisk": 10,
        "conditions": "Rain, Overcast",
        "icon": "rain",
        "stations": "72505394728,KLGA,KNYC,72503014732"
    },
    "row_id": 1,
    "url": "https://csvbase.com/mdfarragher/Manhattan-Hourly-Weather-2023/rows/1"
}

Updating an existing row

PUT to https://<some_user>:<some_api_key>@csvbase.com/mdfarragher/Manhattan-Hourly-Weather-2023/rows/1

Example body
{
    "row": {
        "name": "MANHATTAN",
        "datetime": "2023-01-01T00:00:00",
        "temp": 12.2,
        "feelslike": 12.2,
        "dew": 11.0,
        "humidity": 92.42,
        "precip": 0.219,
        "precipprob": 100,
        "preciptype": "rain",
        "snow": 0.0,
        "snowdepth": 0.0,
        "windgust": 13.0,
        "windspeed": 3.0,
        "winddir": 295,
        "sealevelpressure": 1007.1,
        "cloudcover": 100.0,
        "visibility": 12.3,
        "solarradiation": 0,
        "solarenergy": 0.0,
        "uvindex": 0,
        "severerisk": 10,
        "conditions": "Rain, Overcast",
        "icon": "rain",
        "stations": "72505394728,KLGA,KNYC,72503014732"
    },
    "row_id": 1,
    "url": "https://csvbase.com/mdfarragher/Manhattan-Hourly-Weather-2023/rows/1"
}
Response

Upon success the body you sent will be echoed back, with status code 200.

Deleting a row

DELETE from https://<some_user>:<some_api_key>@csvbase.com/mdfarragher/Manhattan-Hourly-Weather-2023/rows/1

No body is required. Status code 204 upon success.