GraphQL API
AccruPay uses GraphQL, a query language for APIs that provides a more efficient and powerful alternative to REST.
What is GraphQL?
GraphQL is a query language for your API that:
- Allows clients to request exactly the data they need
- Provides a strongly typed schema
- Reduces the number of API calls needed
- Includes built-in introspection and documentation
GraphQL Playground
Explore the schema and test queries using the GraphQL Playground:
- Production: https://api.pay.accru.co/graphql
- QA: https://api.qa.pay.accru.co/graphql
Schema Introspection
Query the schema to see available types and fields:
query IntrospectionQuery {
__schema {
types {
name
description
}
queryType {
name
}
mutationType {
name
}
}
}
Basic Query Example
query GetMerchant {
merchantApi {
id
name
country
}
}
Mutation Example
mutation StartPaymentSession {
merchantApiClientTransactionPaymentSessionStart(
transactionProvider: NUVEI
data: {
amount: "10000"
currency: USD
merchantInternalTransactionCode: "txn-123"
merchantInternalCustomerCode: "customer-456"
billing: {
billingFirstName: "John"
billingLastName: "Doe"
billingEmail: "john@example.com"
billingAddressCountry: US
}
storePaymentMethod: false
}
) {
id
token
providerCode
}
}
Variables
Use variables to pass dynamic values:
mutation StartSession($provider: TransactionProvider!, $data: ClientTransactionPaymentSessionStartData!) {
merchantApiClientTransactionPaymentSessionStart(
transactionProvider: $provider
data: $data
) {
id
token
}
}
Variables JSON:
{
"provider": "NUVEI",
"data": {
"amount": "10000",
"currency": "USD",
"merchantInternalTransactionCode": "txn-123",
"merchantInternalCustomerCode": "customer-456",
"billing": {
"billingFirstName": "John",
"billingLastName": "Doe",
"billingEmail": "john@example.com",
"billingAddressCountry": "US"
},
"storePaymentMethod": false
}
}
Error Handling
GraphQL returns errors in a structured format:
{
"errors": [
{
"message": "Validation failed",
"extensions": {
"code": "VALIDATION_ERROR",
"field": "amount"
}
}
],
"data": null
}
Pagination
Use cursor-based pagination:
query GetTransactions {
merchantApiTransactions(take: 10, skip: 0) {
items {
id
amount
}
pageInfo {
hasNextPage
hasPreviousPage
totalCount
}
}
}
Next Steps
- API Reference - Learn more about the API
- SDK Reference - Use our Node.js SDK
- Transactions - Learn about transactions