How do I view all of my invoices using the API?

Linode Staff

Is there an API call or set of calls I can use to view all of my account's invoices?

1 Reply

You can combine multiple API calls to list all of your invoices. This output can also be used in a more advanced script to generate PDFs or make the output look better. Here is the call I quickly put together:

for i in $(curl -H "Authorization: Bearer $your_token” | jq '.data[] | .id'); do curl -sH "Authorization: Bearer $your_token"$i | python3 -m json.tool; done;

Let’s break that down:

First, gather the invoice IDs by hitting the invoices endpoint and then filter the output using jq.

for i in $(curl -H "Authorization: Bearer $your_token” | jq '.data[] | .id’)

For each iteration in the for loop, print the invoice based on the ID we gathered. The ending python3 -m json.tool is optional and makes the output easier to read in a terminal.

do curl -sH "Authorization: Bearer $your_token"$i | python3 -m json.tool;

This can be refined or changed using other endpoints to gather invoice items or payments. Here are some endpoints that will help you modify the above call.


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct