menu button

Optional calls

Get Usage Records

Use the getUsageRecordsByApiKey query to retrieve all usage records associated with the authenticated API key. This is useful for tracking consumption and auditing usage over time.


Get Usage Records by API Key

No input parameters are required. The records are automatically scoped to the API key used in the request header.

Example GraphQL Query

query GetUsageRecordsByApiKey {
  getUsageRecordsByApiKey {
    id
    email
    amount
    createdAt
  }
}

JavaScript Example (Axios)

import axios from "axios";

export const GET_USAGE_RECORDS_BY_API_KEY = `
  query GetUsageRecordsByApiKey {
    getUsageRecordsByApiKey {
      id
      email
      amount
      createdAt
    }
  }
`;

const getUsageRecordsByApiKey = async () => {
  try {
    const response = await axios({
      method: "POST",
      url: "https://api-v2.speechmind.com/external/v2/graphql",
      headers: {
        "Content-Type": "application/json",
        "x-api-key": process.env.SPEECHMIND_API_KEY,
      },
      data: JSON.stringify({
        query: GET_USAGE_RECORDS_BY_API_KEY,
      }),
    });

    const records = response.data.data.getUsageRecordsByApiKey;
    console.log("Usage Records:", records);

    return records;
  } catch (error) {
    console.error("Error fetching usage records:", error);
  }
};

getUsageRecordsByApiKey();

Response Fields

  • id — unique identifier of the usage record.
  • email — the email associated with the usage entry.
  • amount — the usage amount recorded (e.g. minutes processed).
  • createdAt — timestamp of when the usage was recorded.

Have questions?

Still have questions? Talk to support.