Browsing Resources Using the API

From TeamServer ER/Studio
Jump to: navigation, search

Go Up to Developer Guide

Team Server provides APIs to load and browse information about resources of many types.

Loading Information About a Single Resource

Several APIs let you load the information of a single resource given its ID. If successful, requests to these APIs provide a key with the name of the type of resource (for example, "datasource"). The value of this key is a JSON object (a series of key-value pairs within braces) with detailed information about the target resource, including other resources that are associated with the loaded resource.

For example, performing a GET v1/businessglossaries/15?access_token=<access token> request returns any information about the glossary with ID 15:

{
    "businessglossary": {
        "id": 15,
        "status": "",
        "description": "",
        "link": "/glossary/view.spg?glossaryKey=15",
        "name": "asdf",
        "type": "Glossary",
        "stewards": [
            {
                "id": "1",
                "name": "admin",
                "type": "person",
                "url": "Not available"
            }
        ],
        "url": "/v1/businessglossaries/15"
    }
}

Retrieving a List of Resources

Most APIs let you retrieve a list of resources of a specific type as well, with requests such as GET v1/diagrams?access_token=<access token>. This is an example response:

{
    "metadata_": {
        "limit": 25,
        "totalCount": 3,
        "offset": 0
    },
    "diagrams": [
        {
            "models": [
                {
                    "id": "5",
                    "link": "/object/view.spg?key=5",
                    "name": "Adventure Works",
                    "type": "Physical",
                    "url": "/v1/models/5"
                },
                {
                    "id": "4",
                    "link": "/object/view.spg?key=4",
                    "name": "Adventure Works DW",
                    "type": "Physical",
                    "url": "/v1/models/4"
                },
                {
                    "id": "3",
                    "link": "/object/view.spg?key=3",
                    "name": "Logical",
                    "type": "Logical",
                    "url": "/v1/models/3"
                }
            ],
            "id": 2,
            "author": "Product Management",
            "createdAt": 1369928964,
            "company": "My Company",
            "link": "/object/view.spg?key=2",
            "name": "Adventure Works.DM1",
            "fileName": "Adventure Works.DM1",
            "type": "Diagram",
            "url": "/v1/diagrams/2",
            "version": "1.1"
        },
        {
            "models": [
                {
                    "id": "5800",
                    "link": "/object/view.spg?key=5800",
                    "name": "Logical",
                    "type": "Logical",
                    "url": "/v1/models/5800"
                }
            ],
            "id": 5799,
            "author": "Product Management",
            "createdAt": 1369928437,
            "company": "My Company",
            "link": "/object/view.spg?key=5799",
            "name": "e-Commerce Order Shopping Cart",
            "fileName": "e-Commerce Order Shopping Cart.dm1",
            "type": "Diagram",
            "url": "/v1/diagrams/5799",
            "version": "1.0"
        },
        {
            "models": [
                {
                    "id": "6106",
                    "link": "/object/view.spg?key=6106",
                    "name": "Logical",
                    "type": "Logical",
                    "url": "/v1/models/6106"
                },
                {
                    "id": "6108",
                    "link": "/object/view.spg?key=6108",
                    "name": "Migration Project (Oracle 8i)",
                    "type": "Physical",
                    "url": "/v1/models/6108"
                },
                {
                    "id": "6107",
                    "link": "/object/view.spg?key=6107",
                    "name": "Northwind Production (SQL Server 2000)",
                    "type": "Physical",
                    "url": "/v1/models/6107"
                }
            ],
            "id": 6105,
            "author": "Product Management",
            "createdAt": 1369929045,
            "company": "My Company",
            "link": "/object/view.spg?key=6105",
            "name": "Northwind Sample",
            "fileName": "Northwind.dm1",
            "type": "Diagram",
            "url": "/v1/diagrams/6105",
            "version": "1.0"
        }
    ]
}

Filtering Lists of Resources

You can filter lists of resources by the first letter of the names of its resources, or using search terms.

To filter by the first letter of the name, use the alphaFilter parameter in the query string of your request. For example: GET v1/entities/5804/attributes?alphaFilter=Z&access_token=<access token>

To filter using search terms, use the q parameter in the query strings of your request. For example: GET v1/tables?q=account&access_token=<access token>

Paginating Results

To paginate a list of resources, you can include the following parameters in the query string of your request:

  • "limit" lets you define the maximum number of resources to retrieve.
  • "offset" lets you define a number of resources to skip.

For example, the following request would return a list of entities, filtered so that you only get the results from the 26th to the 35th: GET v1/entities?limit=10&offset=25&access_token=<access token>

When you retrieve a list of resources, in addition to the key that contains the list of resources, there is a special key, "metadata_", which includes filtering information. This key provides a JSON object with information about any used filtering and pagination options, including the total number of resources available. You can use this information in the pagination logic of your client application.

See Also