Obtain an API's Details

Using the API playground (API Hub)

  1. To query for an API's details, you must add an id argument to the query. This is so the server knows which API's details to return. Paste the following query in the GQL Query textbox in the RapidAPI playground (API Hub), replacing the id with any valid API's id. You can obtain an API id using RapidAPI Studio ([HUB URL]/studio > Hub Listing (for any API) > Endpoints > OpenAPI > API Details) or the Provider Dashboard ([HUB URL]/provider > Definition (for any API) > API Specs). You can also obtain this information programmatically.

๐Ÿ“˜

If the API is private, you must make this query using a context that has access to the API (either as an owner or by being invited to use the API). If the private API is owned by a team, you must include the x-rapidapi-identity-key header. See GraphQL Platform API Authorization for more information.

query {
  api(id: "api_15d502af-e297-4f9d-b275-xxxxxxxxxxxxx") {
    id
    name
    slugifiedName
    visibility
    currentVersion {
      name
      id
    }
  }
}
  1. Click Test Endpoint. You should see a response with details of the API. Details about the query and the response are described next.

  2. Details about the query:

    • In the left frame, expand the Queries operation.

    • Scroll down and click api.

    • You should see that the api query expects an argument of id. This was specified in the query above.

    • Notice the FIELDS that you can query for. In the query above, we queried for the name, slugifiedName, visibility, and currentVersion fields.

    • Click the currentVersion field. This brings you to the description of an object of type ApiVersion. Notice that this type includes the name and id fields that are specified under currentVersion in the query above. This is one of the advantages of GraphQL APIs - you can query for data from multiple types in a single query. This is typically done with more than one query in REST APIs.

  3. Details about the code snippet:

    • In the right frame, click Code Snippets.

    • Notice that the request is a POST request to a single endpoint (the root endpoint). All of the GraphQL requests are made to this single endpoint.

    • Notice the data object. It contains a query object containing the query specified in the middle frame's GQL Query textbox.

  4. Details about the response:

    • Expand the details of the response by clicking Results and verify that you have received values in a format that matches the query. This includes details of the currentVersion object.
  5. (Optional) The query above โ€œhard-codesโ€ the api id in the GraphQL document. This is usually not recommended, because the query is not reusable. Change the query to define and use an $apiId variable:

query readApi($apiId: ID!) {
  api(id: $apiId) {
    id
    name
    slugifiedName
    visibility
    currentVersion {
      name
      id
    }
  }
}
  • To assign a value to the $apiId variable, click on the variables button below the GQL Query textbox and enter the following (you will need to change the value of apiId):
{
  "apiId": "api_15d502af-e297-4f9d-b275-xxxxxxxxxx"
}
  • Click Test Endpoint and verify that the query still functions as before. Notice that the variable assignment is included in the code snippet.
  1. Modify the query to add another field. For example, you could add category to the query. Test your results.

Test heading with 2 #'s

Test heading with 3 #'s

One pound

Four pounds