Skip to Content

apiVersion

Fetches the current API version as a string.

Query Structure

query { apiVersion }

Arguments

ArgumentTypeDescriptionRequiredDefault
This query does not accept any argumentsNoN/A

Return Type

String

The query returns a single string representing the current API version.

Examples

Basic Query

query { apiVersion }

Advanced Query

query { apiVersion }

Field Selection

query { apiVersion }

cURL Example

curl -X POST https://www.mystoreurl.com/graphql/0.8.0 \ -H "Content-Type: application/json" \ -d '{"query":"query { apiVersion }"}'

JavaScript Example

async function fetchApiVersion() { const endpoint = "https://www.mystoreurl.com/graphql/0.8.0"; const query = ` query { apiVersion } `; try { const response = await fetch(endpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ query }) }); if (!response.ok) { throw new Error(`Network error: ${response.status} - ${response.statusText}`); } const { data, errors } = await response.json(); if (errors) { console.error("GraphQL errors:", errors); return null; } return data.apiVersion; } catch (error) { console.error("Fetch error:", error); return null; } } // Usage example fetchApiVersion().then(version => { if (version) { console.log("API Version:", version); } });

Response Format

{ "data": { "apiVersion": "0.8.0" } }
  • apiVersion: A string representing the current API version.

Error Handling

Error CodeDescriptionHandling Recommendation
400Bad Request - malformed queryVerify query syntax and structure
500Internal Server ErrorRetry after some time or contact support
Network ErrorsConnectivity issuesImplement retry logic and error logging

Since this query is simple and does not require arguments, errors are typically related to network issues or server problems.

Performance Considerations

  • This query is lightweight and returns a small payload (a single string).
  • It can be called frequently without significant performance impact.
  • No caching is strictly necessary, but clients may cache the version string to reduce repeated calls.
  • Rate limiting may apply globally; adhere to API usage guidelines to avoid throttling.

Authentication

This API currently does not require authentication. However, authentication requirements may be introduced in future versions. Monitor API updates for any changes to authentication requirements.

  • String: The return type representing the API version.

Notes

  • The apiVersion query provides a simple way to programmatically check the API version your client is interacting with.
  • Use this query to implement version checks or compatibility logic in your application.
  • Since it does not accept arguments or return complex data, it is straightforward to integrate and use.
Last updated on