AGIN CloudCloud

API Quickstart

Get started with the AGIN Cloud GraphQL API in under 5 minutes

Get Your API Key

Before making your first GraphQL query, you'll need an API key from the AGIN Cloud console.

Generate Your API Key

  1. Log in to the AGIN Cloud Console
  2. Navigate to Settings > API Keys
  3. Click Generate New Key
  4. Copy and securely store your API key

Important

Your API key will only be shown once. Store it securely and never commit it to version control.

GraphQL Endpoint

All GraphQL requests should be made to:

https://api-preview.agin.africa/graphql

Make Your First Query

Let's verify your API key by fetching your account information.

cURL Example
curl -X POST https://api.agin.cloud/graphql \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "query { account { id name email plan } }"
  }'

Response

{
  "data": {
    "account": {
      "id": "acc_1234567890",
      "name": "Green Valley Farms",
      "email": "admin@greenvalley.com",
      "plan": "PROFESSIONAL"
    }
  }
}

Interactive Playground

Explore the API interactively using our GraphQL Playground:

Open GraphQL Playground

The playground provides:

  • Interactive query builder with auto-complete
  • Real-time schema documentation
  • Query validation and testing
  • No setup required - just add your API key

Example Queries

List Your Farms

query {
  farms(first: 10) {
    edges {
      node {
        id
        name
        location
        totalArea
      }
    }
  }
}

Get Farm Details

query GetFarm($farmId: ID!) {
  farm(id: $farmId) {
    id
    name
    location
    fields {
      id
      name
      size
      cropType
    }
  }
}

Variables:

{
  "farmId": "farm_abc123"
}

Recent Harvests

query {
  harvests(first: 10, orderBy: { harvestDate: DESC }) {
    id
    cropType
    quantity
    unit
    harvestDate
  }
}

Create Your First Record

Here's a simple mutation to create a harvest record:

mutation CreateHarvest($input: CreateHarvestInput!) {
  createHarvest(input: $input) {
    harvest {
      id
      cropType
      quantity
      harvestDate
    }
  }
}

Variables:

{
  "input": {
    "operationId": "op_abc123",
    "cropType": "MAIZE",
    "quantity": 5000,
    "unit": "KG",
    "harvestDate": "2024-10-15"
  }
}

Rate Limits

PlanRequests per minuteRequests per day
Free601,000
Professional60050,000
EnterpriseUnlimitedUnlimited

Error Handling

Errors are returned in a standardized format:

{
  "errors": [
    {
      "message": "The cropType field is required",
      "extensions": {
        "code": "VALIDATION_ERROR"
      }
    }
  ]
}

Common Error Codes

  • UNAUTHENTICATED - Invalid or missing API key
  • FORBIDDEN - Insufficient permissions
  • VALIDATION_ERROR - Input validation failed
  • NOT_FOUND - Resource does not exist
  • RATE_LIMITED - Rate limit exceeded

Next Steps

Need Help?