HomeGuidesRecipesAPI ReferencePython SDK
Alation Help Center

Get Data Sources

Get Data Sources

Description

This API can be used to get the following attributes of data sources in JSON format.

NameDescription
custom_fieldsCustom fields like data source Stewards etc.
dbtypeDatabase type.
titleFriendly title of the database.
descriptionHTML description of the database.
idUnique numeric database identifier.
is_virtualTrue implies that metadata for the data source is updated through API.
uriJDBC URI to the database without the jdbc: prefix.
Example: mysql://mysql.example.com:3306/?allowMultiQueries=true
urlRelative URL path to the data source catalog page.

NOTE: This API is available from version 3.4 and later.

URL

GET /catalog/datasource/?**<params>**

Replace <params> with your list of parameters. Multiple parameters can be combined as PARAM1&PARAM2

URL Parameters

Parameters can be none, any or all of the following:

NameRequiredDescription
idNoUnique numeric ID of a data source. Used to get metadata for a specific data source.
Example: /catalog/datasource/?id=9
titleNoGet all data sources with a given title. Title value is case sensitive.
Example: Get all data sources titled “Teradata Production DB” /catalog/datasource/?title=Teradata Production DB
dbtypeNoGet all data sources with a given type. dbtype value is case sensitive.
Example: Get all data sources whose dbtype is “sqlserver” /catalog/datasource/?dbtype=sqlserver
NOTE: Please refer dbtype values to get a list of data source types.
uriNoGet all data sources with a given uri.
Example: Get all data sources whose uri is “mysql://mysql.example.com:3306/?allowMultiQueries=true”
/catalog/datasource/?uri=mysql://mysql.example.com:3306/?allowMultiQueries=true
is_virtualNoGet all virtual or non-virtual data sources. 'is_virtual' can have two values
true - for data sources whose metadata is updated through API
false - for non-virtual data sources
Example: Get all data sources whose metadata is updated through API i.e. whose 'is_virtual' property is set to 'true' /catalog/datasource/?is_virtual=true
limitNoLimit the number of data sources returned.
Example: /catalog/datasource/?limit=10
skipNoSkip a number of records and return the rest. limit and skip are used for pagination of the results.
Example: /catalog/datasource/?skip=10
custom_fieldsNoFilter results based on Custom Field values. The general format for the filter is: /catalog/datasource/?custom_fields=[<filter1>,<filter2>]

Example Filter: Get all data sources with Jake Magner as a Steward.
/catalog/datasource/?custom_fields=[{"field_name":"Steward", "value":"[email protected]", "value_type":"user"}]

Example Filter: Get all data sources with "Gov Council" (user group) in Stewards.
/catalog/datasource/?custom_fields=[{"field_name":"Steward", "value":"Gov Council", "value_type":"groupprofile"}]

Example Filter: Get all data sources with Season (text field) set to Spring.
/catalog/datasource/?custom_fields=[{"field_name":"Season", "value":"Spring", "value_type":"text"}]
order_byNoOrder results by data source title.
Example: /catalog/datasource/?order_by=title

Headers

HTTP HeaderValue
TOKEN<your_token>

Replace <your_token> with API Token which can be obtained from getToken API call (Get API Token).

Success Response

Content-Type: application/json

Status: 200 OK

Body

[
   {
       "custom_fields":
       [
           {
               "value": "[email protected]",
               "value_type": "user",
               "field_name": "Steward"
           },
           {
               "value": "[email protected]",
               "value_type": "user",
               "field_name": "Steward"
           },
           {
               "value": "the jasons",
               "value_type": "groupprofile",
               "field_name": "Steward"
           },
           {
               "value": "Spring",
               "value_type": "text",
               "field_name": "Season"
           }
       ],
       "dbtype": "teradata",
       "description": "<p>Description of Teradata</p>",
       "id": 9,
       "is_virtual": false,
       "title": "Teradata",
       "uri": "teradata://teradata.alationdata.com/DBS_PORT=1025,COP=OFF,CHARSET=UTF8",
       "url": "/data/9/"
   },
   {
       "custom_fields":
       [
       ],
       "dbtype": "hive2",
       "description": "",
       "id": 50,
       "is_virtual": false,
       "title": "Hive KRB 2",
       "uri": "hive2://test-cdh-2-kerberos.alationdata.com:10000/;principal=hive/[email protected]",
       "url": "/data/50/"
   }
]

Error Response

Invalid Token

Status: 403 Forbidden

Body

{
   "detail": "Authentication failed"
}

Missing Token Header

Status: 403 Forbidden

Body

{
   "detail": "Authentication credentials were not provided."
}

Code Samples

cURL

#!/bin/bash

#This is an example token. Please replace this with your token.
API_TOKEN="3b3bf108-e631-4a26-96ba-942a68182b67"

BASE_URL="http://test-production.alationdata.com/catalog/datasource/"

# List all the data sources
curl -H "TOKEN: ${API_TOKEN}" "$BASE_URL"

# Get a data source by ID
curl -H "TOKEN: ${API_TOKEN}" "${BASE_URL}?id=9"

# Get a data source by its title
curl -H "TOKEN: ${API_TOKEN}" "${BASE_URL}?title=Oracle DB"

# Skip the first three results and return the following 2
curl -H "TOKEN: ${API_TOKEN}" "${BASE_URL}?skip=3&limit=2"

Python

import requests
import json

#This is an example token. Please replace this with your token.
headers = {'Token': 'dd2a282a-c580-48f6-b0c2-601cf2bf991a'}

req = requests.get('http://localhost:8000/catalog/datasource/', headers=headers)
datasources = json.loads(req.text)
for ds in datasources:
    print "ID: %d, Title: %s" % (ds['id'], ds['title'])