Developer Docs

REST API Development Guide

Understanding Data

How Data is Handled

Inside a Flybase app, we have collections, which contain data.

We store all data inside a collection as JSON objects. When we add a new record to a collection, it becomes a document in the existing JSON structure.

For example, if we added a column named furbies to the kaitlyn user under the users collection, our data looks as follows:

		"users": {
				"_id": "uniquedocid-1",
				"username": "kaitlyn",
				"friends": { "jacob": true },
				"name": "Kaitlyn",
				"furbies": { "cocoa": true, "totoa": true }
				"_id": "uniquedocid-2",
				"username": "jacob",
				"_id": "uniquedocid-3",
				"username": "caleb",
Reference a Flybase app

To read and write Flybase data, we need to reference our app.

A Flybase reference consists of three items:

  1. Your API Key, represented by: 74k8064f-cd6f-4c07-8baf-b1d241496eec
  2. The slug of a Flybase app that has been created in your account: web
  3. Finally, the name of a data collection, in this example: posts

	curl -X POST -d '{ "title": "The Black Pearl", "author": "jacks" }' \
	  -H "X-Flybase-API-Key: 74k8064f-cd6f-4c07-8baf-b1d241496eec" \

Data inside a Flybase app is organized by collections, if you are familiar with SQL tables, then this is similar to tables.

Apps must be created inside your Flybase dashboard, but if you call a collection that does not exist already then it will get created the first time you save data to it.

Flybase provides a Dashboard, which displays a visual representation of the data and provides tools for simple administrative tasks.

Passing JSON Web Tokens

If you don't want to pass your API key every time then you can also pass a JSON web token.

This can be generated by passing the following POST query:

	curl -X POST

This will return a JSON object with id_result as the key, copy the contents of id_result to use elsewhere.

Then you can pass the JSON token rather than your API key via one of three ways:

1. Replace the api key with token:YOURJWTTOKEN:

	curl -H "X-Flybase-API-Key: token:MYTOKEN"

2. Pass a Authorization: Bearer header with your JWT token included after the word Bearer:

	curl -H "Authorization: Bearer MYTOKEN

3. Pass the token with the jwttoken query string variable:


Either of these three methods work and provide a handy way to pass your api keys without actually passing your keys.

That's it! Now we're ready to start writing data to Flybase which we'll cover in the next section.