Getting Started

Steps for getting started with Codex.

1. Get your API key ✨

Go to the Codex Dashboard and sign up for an API account.

2. Run your first query

Option 1: Use the SDK (recommended)

Install the SDK to start developing develop on top of the Codex API.

The SDK provides several integration examples as well as the public schema definition language (SDL). You can use graphql-codegen to generate types and queries.

Option 2: Use the language of your choice

Replace <MY_KEY> with your new API key.

  curl \
  -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization:<MY_KEY>" -d '{ "query": "{ getNetworks { name, id } }"}' \
  https://graph.defined.fi/graphql
import axios from "axios";

axios
  .post(
    "https://graph.defined.fi/graphql",
    {
      query: `{
        getNetworks {
          name
          id
        }
      }`
    },{
      headers: {
        "Content-Type": "application/json",
        "Authorization": "<MY_KEY>"
      }
    }
  )
  .then((response) => {
    console.log(response.data);
  });

import requests
import json

url = "https://graph.defined.fi/graphql"

headers = {
  "content_type":"application/json",
  "Authorization": "<MY_KEY>"
}

getNetworks = """query GetNetworksQuery { getNetworks { name id } }"""

response = requests.post(url, headers=headers, json={"query": getNetworks})

print(json.loads(response.text))
<?php

$url = "https://graph.defined.fi/graphql";

$query = array(
    'query' => '{
        getNetworks {
            name
            id
        }
    }'
);

$headers = array(
    'Content-Type: application/json',
    'Authorization: ' . "<MY_KEY>"
);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
package main

import (
  "bytes"
	"fmt"
	"net/http"
	"io/ioutil"
	"encoding/json"
)

func main() {
	url := "https://graph.defined.fi/graphql"
	apiKey := "<MY_KEY>"

	query := `query GetNetworksQuery { getNetworks { name id } }`
	payload := map[string]string{"query": query}
	payloadBytes, _ := json.Marshal(payload)

	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payloadBytes))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", apiKey)

	client := &http.Client{}
	res, _ := client.Do(req)
	defer res.Body.Close()

	body, _ := ioutil.ReadAll(res.Body)

	var response map[string]interface{}
	json.Unmarshal(body, &response)

	fmt.Println(response)
}


require 'net/http'
require 'json'

uri = URI('https://graph.defined.fi/graphql')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

headers = {
  'Content-Type' => 'application/json',
  'Authorization' => '<MY_KEY>'
}

query = {
  query: '{
    getNetworks {
      name
      id
    }
  }'
}

request = Net::HTTP::Post.new(uri.path, headers)
request.body = query.to_json

response = http.request(request)
puts response.body

Your key must be included as Authorization in the header of every request.

Make sure to keep your API key private and secure.

3. Start building

  • Examples: Visit the quickstart page in each section for ideas and help integrating your app. Note that most sections in the docs have a websockets grouping if you would like to use real-time, streaming data.
  • Explorer: Check out the 🧭 Explorer if you'd like to scope out the API and run some queries right now.
  • Codex API endpoints used by Defined: If you'd like to see what endpoints powers each feature on Defined Trading Terminal, visit the app, go to General Settings and enable the Show Codex API endpoints setting to overlay red indicator dots on the UI.

πŸ‘‹

Join our Discord

Ask questions, share what you're working on and request new features πŸ‘¬πŸ‘­