Fast and easy way to test the Fibery API using Postman

I hit a few hurdles getting my first API request to work in Postman so I figured I would throw together a quick guide for anyone that wants to try out the API but isn’t a developer or doesn’t want to use cURL.

Getting your API token

This process will very likely change in the future but for now:

  1. Open a tab to your https://YOUR_ACCOUNT_HERE.fibery.io/ page
  2. Open the developer console by pressing F12 or Cmd+Opt+J on Mac (more info here)
  3. Paste in the code below (WARNING: you should never run unknown console commands, the one below is copy pasted from the official API)
fetch(`https://${window.location.host}/api/tokens`, { method: 'POST' })
  .then(res => res.json())
  .then(obj => console.log("Your API token:", obj.value));
  1. If your token isn’t printed in the console you might have to click on one of the messages to see it. End result should look something like below. Temporarily copy your API token somewhere secure.

Setting up Fibery authentication in your Postman collection

  1. Create a new collection in Postman

  2. In the Authorization tab, for Type select API Key for Key enter Authorization, for Value enter Token {{token}} and Add to should be Header

  3. Head over to the Variables tab and create a new Variable token with the Initial Value set to whatever your API token was

  4. Click Save

Sending an API request

  1. Create a new request in your Fibery collection and under the requests Authorization tab make sure the Type is set to Inherit auth from parent
  2. a) Set the request type to POST, b) set the request URL to https://YOUR_ACCOUNT_HERE.fibery.io/api/commands and c) under Headers tab add a header with the Key of Content-Type and a Value of application/json
  3. Head over to the request’s Body tab and select raw. You should now be able to enter and send your API request. For example, here is how you get the schema:
3 Likes

By the way, is there a way to get all values in a table?

Similar to SQL: SELECT * FROM table_name;

I’m imagining it would be something like below. How far off am I?

"query": {
"q/from": "table_name",
"q/select": "*",
"q/limit": 3
}
    {
    "command": "fibery.entity/query",
    "args": {
        "query": {
        "q/from": "<App Name>/<Type Name>",
        "q/select": ["<App Name>/Name", "<App Name>/<Field Name>"],
        "q/limit": "q/no-limit"
        }
    }
    }
]

This worked for me. There is a mention in the api docs about the special no-limit criteria.

Edit: Sorry, I misread. You want all columns, not all entities. Looks like selecting all fields isn’t supported based on the API documentation saying:

query. q/select: Array of primitive Fields, entity Field objects, objects with entity collection Fields subqueries and entity collection Field aggregates.

1 Like

No, not for all fields in an entity. You will need to retrieve your workspace schema and find all the field names in your type.

I see. This is outside the scope of using Postman, but what’s a good approach here, to get the schema and cache it for some duration, making API calls against that cached version of the schema?

I think that’s the best we can do at this point, but:

It would be great if there was a (fast) API call to get the “version number” of the Workspace schema, so we could easily discover if our cached schema was out of date.
Feature Request