Overview

We’re expanding our API to include bulk operations and better handling of large datasets. Ultimately, this API will replace the current one (api.luabase.com), but isn’t quite ready for prime time. The new API is currently hosted at q.luabase.com (q is for query).

<aside> 💡 You can grab your api_key in Settings (click the cog icon in the left sidebar)

</aside>

Basic Usage

The fastest way to get started is to create a block in the app and click on the “View API” button to the left of the “Run” button. You’ll also see a button to click to copy your API key.

<aside> 💡 You can control the # of rows returned with the block.details.limit

</aside>

import requests
import os

LUABASE_API_KEY = os.getenv('LUABASE_API_KEY')

url = "<https://q.luabase.com/run>"

payload = {
  "block": {
    "data_uuid": "YOUR_BLOCK_UUID",
		"details": {
            "parameters": {
                "min_block_number": {
                    "value": 15000000,
                    "type": "value",
                },
            },
						"limit": 2000
        },
  },
  "api_key": LUABASE_API_KEY,
}
headers = {"content-type": "application/json"}
response = requests.request("POST", url, json=payload, headers=headers)
data = response.json()

Dynamic SQL

import requests
import os

LUABASE_API_KEY = os.getenv('LUABASE_API_KEY')

url = "<https://q.luabase.com/run>"

sql = '''
select 1
'''

payload = {
  "block": {
    "details": {
      "sql": sql,
    }
  },
	  "api_key": LUABASE_API_KEY,
}
headers = {"content-type": "application/json"}
response = requests.request("POST", url, json=payload, headers=headers)
data = response.json()

Autogenerated Docs

We use FastAPI and thus benefit from the automatically generated documentation here.