Available APIs
GraphQL API
The primary API for querying and mutating infrastructure data. GraphQL provides:- Flexible querying with nested relationships
- Schema introspection
- Real-time subscriptions via WebSockets
- Branch-aware operations
- Time-travel queries with the
atparameter
/graphql/{branch_name}
See GraphQL API for detailed documentation.
REST API
The REST API provides endpoints for specific operations:- Artifact management
- File operations
- Schema retrieval
- Diff operations
- Stored query execution
/api
See REST API for detailed documentation.
Python SDK
The official Python SDK provides a high-level interface for:- Type-safe operations
- Object-oriented access to nodes and relationships
- Async/await support
- Automatic authentication handling
API Features
Branch Support
All APIs support Git-like branching for isolated changes:- Query data from specific branches
- Make changes in feature branches
- Merge branches with conflict detection
Time-Travel Queries
Query historical data using theat parameter:
- Absolute timestamps:
2024-01-15T10:30:00Z - Relative times:
-1h,-7d,-30m
Authentication
All authenticated endpoints support:- JWT tokens (access and refresh)
- API keys
- OAuth 2.0 (Google, custom providers)
- OIDC (OpenID Connect)
Interactive Documentation
Infrahub provides interactive API documentation:- Swagger UI:
/api/docs- Interactive REST API documentation - ReDoc:
/api/redoc- Alternative REST API documentation - GraphQL Playground: Available at the GraphQL endpoint for interactive query building
API Versioning
The API version is returned in the/api/info endpoint:
Error Handling
GraphQL Errors
GraphQL returns errors in the response alongside data:REST API Errors
REST endpoints use standard HTTP status codes:200- Success400- Bad Request401- Unauthorized403- Forbidden404- Not Found422- Validation Error500- Internal Server Error
Next Steps
- Authentication Methods - Learn how to authenticate API requests
- GraphQL API - Explore the GraphQL API
- REST API - Browse REST endpoints
- Rate Limits - Understand API rate limiting