Api limits and issues;

Hey guys,

Can you explain why the API uses pagination, is this a limit on my trial
account? I’m running into some limitations and it seems to stem from only
been given 25 results per request. I’ve looked into it and found the
documentation which mentions the pagination but I don’t understand the
reasons for it.

If I want to output a list of all projects and all contacts but to do so I
have two choices;

1, import all api results into my own database and run this on a
cron/schedule to make sure we get all items.
2, somehow figure out how many projects are on the system in total and work
out how many pages there are and then begin getting the api results one
page at a time.

Both of these causes problems, how am I supposed to give the user the
ability to show all projects where Organisation Name = Test if I cannot get
a list of all projects to begin with?

Am I missing something in the documentation or not understanding what
features the API provides? Can I get a list of filtered projects via the
API?

Also, to look up a single project or update it you need the ID but this
only seems to be included in the response as part of the URL so I had to
parse the URL to get ID, is this how it is supposed to be done? Why is the
ID not included as a standalone field in the project data?

Thanks for your response David.

Your explanation clears up a lot of misunderstandings I had and I will use
the points you mention to improve my code.On Monday, January 26, 2015 at 12:33:28 PM UTC, David Jones wrote:

Hey there,

Thanks for your message and sorry it has taken me a few days to get back
to you.

Response pagination isn’t a limit of your trial account, it’s the default
behaviour for all our API endpoints.

We spread the data across multiple pages to avoid flooding your
integration with enormous response bodies.
It’s not uncommon for our older and busier accounts to have hundreds of
even thousands of contacts, projects and invoices.
If all invoices (for example) were to be enumerated in a single response,
the payload would be enormous!

If the pagination is getting in the way, there are certain headers you can
set to make things easier.
For example, rather than the default 25 items per page, you can request
(upto) 100 items in a single response. That way, you can fetch an entire
collection of entities (invoices, contacts) in fewer API requests:

You can also easily jump to the last page of pagination using the URLs in
the “Link” header at the top of each response:

https://api.freeagent.com/v2/invoices?page=10&per_page=50; rel=“last”

Note that the page number is included as an argument in the URL, so once
you know the number of the “last” page, you can easily determine how many
pages need to be traversed to ensure you gather all of the data.

To answer your final question, about parsing a project ID from the URL,
you should be able to reference the project using the absolute (full) URL
directly:
Infact, that’s the way our API is designed to handle all references to
existing entities, using their full URL (rather than purely their ID).

I hope this helps to get you started!

Dave J

On 21 January 2015 at 15:56, <n…@pcmmedia.eu <javascript:>> wrote:

Hey guys,

Can you explain why the API uses pagination, is this a limit on my trial
account? I’m running into some limitations and it seems to stem from only
been given 25 results per request. I’ve looked into it and found the
documentation which mentions the pagination but I don’t understand the
reasons for it.

If I want to output a list of all projects and all contacts but to do so
I have two choices;

1, import all api results into my own database and run this on a
cron/schedule to make sure we get all items.
2, somehow figure out how many projects are on the system in total and
work out how many pages there are and then begin getting the api results
one page at a time.

Both of these causes problems, how am I supposed to give the user the
ability to show all projects where Organisation Name = Test if I cannot get
a list of all projects to begin with?

Am I missing something in the documentation or not understanding what
features the API provides? Can I get a list of filtered projects via the
API?

Also, to look up a single project or update it you need the ID but this
only seems to be included in the response as part of the URL so I had to
parse the URL to get ID, is this how it is supposed to be done? Why is the
ID not included as a standalone field in the project data?


You received this message because you are subscribed to the Google Groups
“FreeAgent API” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to freeagent_ap...@googlegroups.com <javascript:>.
To post to this group, send email to freeag...@googlegroups.com
<javascript:>.
Visit this group at http://groups.google.com/group/freeagent_api.
For more options, visit https://groups.google.com/d/optout.


David Jones
Senior Support Engineer

FreeAgent

Hey there,

Thanks for your message and sorry it has taken me a few days to get back to
you.

Response pagination isn’t a limit of your trial account, it’s the default
behaviour for all our API endpoints.

We spread the data across multiple pages to avoid flooding your integration
with enormous response bodies.
It’s not uncommon for our older and busier accounts to have hundreds of
even thousands of contacts, projects and invoices.
If all invoices (for example) were to be enumerated in a single response,
the payload would be enormous!

If the pagination is getting in the way, there are certain headers you can
set to make things easier.
For example, rather than the default 25 items per page, you can request
(upto) 100 items in a single response. That way, you can fetch an entire
collection of entities (invoices, contacts) in fewer API requests:

You can also easily jump to the last page of pagination using the URLs in
the “Link” header at the top of each response:

https://api.freeagent.com/v2/invoices?page=10&per_page=50; rel=“last”

Note that the page number is included as an argument in the URL, so once
you know the number of the “last” page, you can easily determine how many
pages need to be traversed to ensure you gather all of the data.

To answer your final question, about parsing a project ID from the URL, you
should be able to reference the project using the absolute (full) URL
directly:
Infact, that’s the way our API is designed to handle all references to
existing entities, using their full URL (rather than purely their ID).

I hope this helps to get you started!

Dave JOn 21 January 2015 at 15:56, nd@pcmmedia.eu wrote:

Hey guys,

Can you explain why the API uses pagination, is this a limit on my trial
account? I’m running into some limitations and it seems to stem from only
been given 25 results per request. I’ve looked into it and found the
documentation which mentions the pagination but I don’t understand the
reasons for it.

If I want to output a list of all projects and all contacts but to do so I
have two choices;

1, import all api results into my own database and run this on a
cron/schedule to make sure we get all items.
2, somehow figure out how many projects are on the system in total and
work out how many pages there are and then begin getting the api results
one page at a time.

Both of these causes problems, how am I supposed to give the user the
ability to show all projects where Organisation Name = Test if I cannot get
a list of all projects to begin with?

Am I missing something in the documentation or not understanding what
features the API provides? Can I get a list of filtered projects via the
API?

Also, to look up a single project or update it you need the ID but this
only seems to be included in the response as part of the URL so I had to
parse the URL to get ID, is this how it is supposed to be done? Why is the
ID not included as a standalone field in the project data?


You received this message because you are subscribed to the Google Groups
“FreeAgent API” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to freeagent_api+unsubscribe@googlegroups.com.
To post to this group, send email to freeagent_api@googlegroups.com.
Visit this group at http://groups.google.com/group/freeagent_api.
For more options, visit https://groups.google.com/d/optout.

David Jones
Senior Support Engineer

FreeAgent