Understanding Credit Usage

Hello -

I am trying to query warehouse product inventory and am noticing that the credit usage for the same request decreases my remaining credits more than I expect. Would someone be able to help me understand how the credit allotment and degradation works?

I’ve included my query below (shoutout to @tomasw for helping me with logic) and the results for the first and second run (~5 seconds apart) below. The first result shows remaining credits as 700 and the second result shows 549. My query is only requesting the 1st 10 results back for each run so I’m unsure why my credits would go down by 151?

Please let me know.

Thanks,
rubix3

Here is my query:
query {
user_quota {
credits_remaining
max_available
increment_rate
}
warehouse_products(warehouse_id: “V2FyZWhvdXNlOjcxNDU=”) {
request_id
data(first: 10) {
edges {
node {
id
legacy_id
account_id
warehouse_id
price
value
on_hand
reserve_inventory
allocated
available
created_at
updated_at
}
}
}
}
}

After the first run:
{
“data”: {
“user_quota”: {
“credits_remaining”: 700,
“max_available”: 1001,
“increment_rate”: 15
},
“warehouse_products”: {
“request_id”: “5e2cbb1d7c723b908f78b52b”,
“data”: {
“edges”: [
{
“node”: {
“id”: “UHJvZHVjdDozMDA5MzIyNzE=”,
“legacy_id”: 300932271,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “0.0000”,
“value”: “0.0000”,
“on_hand”: 0,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 0,
“created_at”: “2020-01-20T20:56:12+00:00”,
“updated_at”: “2020-01-20T21:35:40+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDI0NDg=”,
“legacy_id”: 289542448,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “21.9900”,
“value”: “9.3100”,
“on_hand”: 4,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 4,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-19T03:07:48+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDI0NDE=”,
“legacy_id”: 289542441,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “77.9900”,
“value”: “32.2800”,
“on_hand”: 4,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 4,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-19T03:07:48+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDI4MTk=”,
“legacy_id”: 289542819,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “10.9900”,
“value”: “8.1600”,
“on_hand”: 8,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 8,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-19T03:07:48+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDI4MTA=”,
“legacy_id”: 289542810,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “10.9900”,
“value”: “8.7200”,
“on_hand”: 12,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 12,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-15T16:48:08+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDI4MTY=”,
“legacy_id”: 289542816,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “66.9900”,
“value”: “56.8500”,
“on_hand”: 5,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 5,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-19T03:07:48+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDMzNjE=”,
“legacy_id”: 289543361,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “5.9900”,
“value”: “5.7900”,
“on_hand”: 25,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 25,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-24T18:51:45+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDI3NDc=”,
“legacy_id”: 289542747,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “2.9900”,
“value”: “2.2500”,
“on_hand”: 14,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 14,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-15T16:48:08+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDMxMTk=”,
“legacy_id”: 289543119,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “14.9900”,
“value”: “8.3900”,
“on_hand”: 8,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 8,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-19T03:07:48+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDMwNjg=”,
“legacy_id”: 289543068,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “15.9900”,
“value”: “15.0100”,
“on_hand”: 8,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 8,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-19T03:07:48+00:00”
}
}
]
}
}
}
}

Second run (~5 seconds later)
{
“data”: {
“user_quota”: {
“credits_remaining”: 549,
“max_available”: 1001,
“increment_rate”: 15
},
“warehouse_products”: {
“request_id”: “5e2cbb276a45943716a85d4d”,
“data”: {
“edges”: [
{
“node”: {
“id”: “UHJvZHVjdDozMDA5MzIyNzE=”,
“legacy_id”: 300932271,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “0.0000”,
“value”: “0.0000”,
“on_hand”: 0,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 0,
“created_at”: “2020-01-20T20:56:12+00:00”,
“updated_at”: “2020-01-20T21:35:40+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDI0NDg=”,
“legacy_id”: 289542448,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “21.9900”,
“value”: “9.3100”,
“on_hand”: 4,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 4,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-19T03:07:48+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDI0NDE=”,
“legacy_id”: 289542441,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “77.9900”,
“value”: “32.2800”,
“on_hand”: 4,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 4,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-19T03:07:48+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDI4MTk=”,
“legacy_id”: 289542819,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “10.9900”,
“value”: “8.1600”,
“on_hand”: 8,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 8,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-19T03:07:48+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDI4MTA=”,
“legacy_id”: 289542810,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “10.9900”,
“value”: “8.7200”,
“on_hand”: 12,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 12,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-15T16:48:08+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDI4MTY=”,
“legacy_id”: 289542816,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “66.9900”,
“value”: “56.8500”,
“on_hand”: 5,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 5,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-19T03:07:48+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDMzNjE=”,
“legacy_id”: 289543361,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “5.9900”,
“value”: “5.7900”,
“on_hand”: 25,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 25,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-24T18:51:45+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDI3NDc=”,
“legacy_id”: 289542747,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “2.9900”,
“value”: “2.2500”,
“on_hand”: 14,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 14,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-15T16:48:08+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDMxMTk=”,
“legacy_id”: 289543119,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “14.9900”,
“value”: “8.3900”,
“on_hand”: 8,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 8,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-19T03:07:48+00:00”
}
},
{
“node”: {
“id”: “UHJvZHVjdDoyODk1NDMwNjg=”,
“legacy_id”: 289543068,
“account_id”: “QWNjb3VudDo0NDU3”,
“warehouse_id”: “V2FyZWhvdXNlOjcxNDU=”,
“price”: “15.9900”,
“value”: “15.0100”,
“on_hand”: 8,
“reserve_inventory”: 0,
“allocated”: 0,
“available”: 8,
“created_at”: “2019-11-01T14:41:43+00:00”,
“updated_at”: “2020-01-19T03:07:48+00:00”
}
}
]
}
}
}
}

1 Like

HI @rubix3 !

This could be because the available field inside warehouse_products has a cost of 30, and it increases the complexity of the query significantly.

The reason for this is that it has complex calculations to figure out the available quantities (to check if it’s virtual, if its a Kit, then component with lower inventory, sell ahead quantity of Purchase Orders, etc etc)

Let me know if this doesn’t help.
Thanks!
Tom

Hello @tomasw -

Thank you for the feedback! That does make sense to me and I’m wondering if there is any other way to gather this information without requiring an expensive credit usage to gather this field.

Please let me know when you have a chance.

Thanks again!
-Nick

Hi Nick,

You can find out how expensive a query is going to be by using “analyze: true” next to your warehouse_id, like this:

query {
    user_quota {
        credits_remaining
        max_available
        increment_rate
    }
    warehouse_products(warehouse_id: “V2FyZWhvdXNlOjcxNDU=”, analyze: true) {
        request_id
        ...

That will return the usage and credit info without actually running the query or spending any credits.

Jeremy

Hello @jeremyw -

Ah, yes! I will use that going forward when building out my api.

Thanks again!
rubix3