> ## Documentation Index
> Fetch the complete documentation index at: https://docs.crazygoldfish.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API quickstart

> Get a CrazyGoldFish access token and make your first API call in five minutes, with examples in cURL, Python, and JavaScript.

This quickstart takes you from nothing to a working API call. You need a terminal, or Python or Node.js installed.

<Steps>
  <Step title="Get API credentials">
    [Contact CrazyGoldFish](https://www.crazygoldfish.com/#comp-lxumousa) for an API username and password. Store them on your server, for example in environment variables.

    <Warning>
      Call the API from your server only. Don't put credentials or tokens in browser or mobile app code.
    </Warning>
  </Step>

  <Step title="Get an access token">
    An access token is a temporary key that proves requests come from your account. Send your credentials as form data to `POST /token` to get one.

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST https://api.crazygoldfish.com/token \
        -d "username=YOUR_USERNAME" \
        -d "password=YOUR_PASSWORD"
      ```

      ```python Python theme={null}
      import requests

      BASE_URL = "https://api.crazygoldfish.com"

      response = requests.post(
          f"{BASE_URL}/token",
          data={"username": "YOUR_USERNAME", "password": "YOUR_PASSWORD"},
      )
      response.raise_for_status()
      access_token = response.json()["access_token"]
      ```

      ```javascript JavaScript theme={null}
      const BASE_URL = "https://api.crazygoldfish.com";

      const response = await fetch(`${BASE_URL}/token`, {
        method: "POST",
        body: new URLSearchParams({ username: "YOUR_USERNAME", password: "YOUR_PASSWORD" }),
      });
      if (!response.ok) throw new Error(await response.text());
      const { access_token: accessToken } = await response.json();
      ```
    </CodeGroup>

    ```json Response theme={null}
    {
      "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
      "token_type": "bearer"
    }
    ```
  </Step>

  <Step title="Make your first call">
    List the education boards you can use. Send the token in the `Authorization` header.

    <CodeGroup>
      ```bash cURL theme={null}
      curl https://api.crazygoldfish.com/metadata/v1/board \
        -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
      ```

      ```python Python theme={null}
      headers = {"Authorization": f"Bearer {access_token}"}

      boards = requests.get(f"{BASE_URL}/metadata/v1/board", headers=headers).json()
      print(boards)
      ```

      ```javascript JavaScript theme={null}
      const headers = { Authorization: `Bearer ${accessToken}` };

      const boards = await (await fetch(`${BASE_URL}/metadata/v1/board`, { headers })).json();
      console.log(boards);
      ```
    </CodeGroup>

    ```json Response theme={null}
    [
      { "id": "baf36573-d049-4636-9c4b-bc9cda6270fe", "name": "CBSE" }
    ]
    ```

    You now have a working integration. Board IDs are used when you create lesson plans and worksheets.
  </Step>

  <Step title="Build something">
    <CardGroup cols={2}>
      <Card title="Generate a worksheet" icon="list-check" href="/api-reference/guides/generate-a-worksheet">
        A complete guide from topic to answer key.
      </Card>

      <Card title="Browse all APIs" icon="grid-2" href="/api-reference/all-apis">
        See every product and the conventions each one follows.
      </Card>
    </CardGroup>
  </Step>
</Steps>

## If something goes wrong

| Response                                | Cause                                         | Fix                                                                   |
| --------------------------------------- | --------------------------------------------- | --------------------------------------------------------------------- |
| `401` `Incorrect username or password`  | Wrong credentials                             | Check the username and password                                       |
| `401` `No client found with user`       | The API user isn't linked to a client account | [Contact CrazyGoldFish](https://www.crazygoldfish.com/#comp-lxumousa) |
| `422` `Field required`                  | Credentials sent as JSON instead of form data | Send `username` and `password` as form fields                         |
| `401` `Authorization header is missing` | No `Authorization` header on the call         | Add `Authorization: Bearer YOUR_ACCESS_TOKEN`                         |
