lever / postings-api

API documentation and examples for the lever postings REST API
184 stars 38 forks source link

Total number of job postings #24

Open achimmer opened 7 years ago

achimmer commented 7 years ago

I'm trying to implement pagination with job postings. How do I get the total number of job postings while using the limit parameter?

rahuln93 commented 6 years ago

Could you figure this out? I am trying to do the same thing.

rkstedman commented 6 years ago

Hello! Thanks for your question. We do not provide the total number of pages or postings. The limit only allows you to set the total per page. If you have 95 published postings and you set the limit to 10, you'll have ten pages of postings:

GET /v0/postings/SITE?limit=10 # page 1
GET /v0/postings/SITE?skip=10&limit=10 # page 2
GET /v0/postings/SITE?skip=20&limit=10 # page 3
...
GET /v0/postings/SITE?skip=90&limit=10 # page 10 (only includes 5 results)

You know you've reached the last page when your request returns fewer results than the provided limit.

Hope this helps!

achimmer commented 6 years ago

@rkstedman That works until your last skip of results is the same size as the limit. Which means you have to do an API call only to return no results.

The alternative implies you have to do a separate API call without limit & skip to calculate the number of results, and then factor your pagination that way.

Ideally, the API postings results should return the total if possible. Feature request?

achimmer commented 6 years ago

@rahuln93 , I have a working Code Pen with filters and pagination: https://codepen.io/achimmer/pen/XgLoPM

I'm going to refactor my pagination logic (since I don't know the total results using limit & skip) by making a separate API call (3 http requests every time I render job postings). That way I save the user from having to paginate all the way to the end and then serve no results. But this is forthcoming.

roylindauer commented 6 years ago

Having the total number of records available in the header of the response would be extremely helpful.