Skip to content

Sources

A Source (a data feed provider) is a stored connection to an external system that Feeds read their rows from.

Source Type

Value Description
MY_SQL MySQL database
MS_SQL Microsoft SQL Server database
SPREADSHEET A spreadsheet file on the server
GOOGLE_SHEETS A Google Sheets spreadsheet
GOOGLE_FIREBASE Google Firebase
HTTP An HTTP endpoint
MONGO_DB MongoDB database

Get all Source

GET /api/data/sources

Returns all the Sources available

Response

The response is an array of Sources

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[
    {
        "_id": "65e06cac93d4be23246f8f3d",
        "type": "GOOGLE_SHEETS",
        "name": "Sources-DB",
        "config": {
            "api_key": "",
            "spreadsheet": "1PzUPFBKrPDDCJMANKjzW_ofVNl_5tL05nPBCWQJ7DCk"
        },
        "tables": [],
        "createdAt": "2024-02-29T11:38:20.925Z",
        "updatedAt": "2024-02-29T11:38:20.925Z",
        "__v": 0,
        "_type": "DATAFEEDPROVIDER"
    },
    {
        "_id": "65e0b0fd93d4be23246f9014",
        "type": "GOOGLE_SHEETS",
        "name": "MySource",
        "config": {
            "api_key": "",
            "spreadsheet": "1hphETItGid_WB4ix9zENdoKGPKHdeB0lMjL_dJPnTGU"
        },
        "tables": [],
        "createdAt": "2024-02-29T16:29:49.351Z",
        "updatedAt": "2024-02-29T16:29:49.351Z",
        "__v": 0,
        "_type": "DATAFEEDPROVIDER"
    }
]

Supports the list query parameters.

Get the Source by ID

GET /api/data/sources/[ID]

Returns the information of the Source specified

Parameter Value Description
ID ID The Uuid or the name of the Source. The name is matched case-insensitively

Response

The response is the information of the Source specified

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
    "_id": "65e0b0fd93d4be23246f9014",
    "type": "GOOGLE_SHEETS",
    "name": "MySource",
    "config": {
        "api_key": "",
        "spreadsheet": "1hphETItGid_WB4ix9zENdoKGPKHdeB0lMjL_dJPnTGU"
    },
    "tables": [],
    "createdAt": "2024-02-29T16:29:49.351Z",
    "updatedAt": "2024-02-29T16:29:49.351Z",
    "__v": 0,
    "_type": "DATAFEEDPROVIDER"
}

An unknown id or name answers 404.

Create a Source

POST /api/data/sources

Creates a new Source and connects to it.

Request

Parameter Type Description
overwrite Boolean (query) When a source of the same name already exists, replace it instead of failing

Request Body

1
2
3
4
5
6
7
8
9
{
    "type": "GOOGLE_SHEETS",
    "name": "MySource",
    "config": {
        "api_key": "",
        "spreadsheet": "1hphETItGid_WB4ix9zENdoKGPKHdeB0lMjL_dJPnTGU"
    },
    "tables": []
}
Parameter Type Description
type Source Type The kind of system to connect to
name String The name of the Source. It must be unique
config Object The connection settings. What it holds depends on type
tables Array Optional list of table names

Response

The created Source. A name already in use fails with 500 and DataFeedProvider 'MySource' already exists, unless overwrite=true was given.

Update a Source

PUT /api/data/sources/[ID]

Updates the Source. The body is a partial Source.

Parameter Value Description
ID ID The Uuid or the name of the Source

Delete a Source

DELETE /api/data/sources/[ID]

Deletes the Source and closes its connection.

Parameter Value Description
ID ID The Uuid or the name of the Source

Verify a Source Configuration

POST /api/data/sources/verify/[TYPE]

Tests a connection configuration without saving it. Use it to validate what an operator typed before creating the Source.

Request

Parameter Type Description
TYPE Source Type The kind of system to test. The value is upper-cased before use

Request Body

The config object that would be stored on the Source.

1
2
3
4
{
    "api_key": "",
    "spreadsheet": "1hphETItGid_WB4ix9zENdoKGPKHdeB0lMjL_dJPnTGU"
}

Query a Source

POST /api/data/sources/[ID]/query

Runs a query against the Source and returns the rows.

Request

Parameter Value Description
ID ID The Uuid or the name of the Source

Request Body

1
2
3
4
{
    "query": "SELECT * FROM players",
    "args": {}
}
Parameter Type Description
query String The query to run. Its syntax depends on the Source's type
args Object Named arguments referenced by the query

Two variants take the same body:

  • POST /api/data/sources/[ID]/preview returns a limited preview of the result.
  • POST /api/data/sources/[ID]/tables returns the tables available on the Source.

Query without a saved Source

In place of the id, pass instant:[TYPE] to run a query through a temporary provider of that type, without creating a Source first:

POST /api/data/sources/instant:HTTP/query