Getting all the records via api - api

I have open api mention in link below
https://npiregistry.cms.hhs.gov/registry/help-api
Considering I need to extract all the records for below api query for city= Baltimore
https://npiregistry.cms.hhs.gov/api/?version=2.1&city=baltimore
Using limit and skip
https://npiregistry.cms.hhs.gov/api/?version=2.1&city=baltimore&limit=200&skip=1000
Problem is by using skip and limit,I can get only 1200 records in 6 iteration skipping 0,200,400,600,800 and Max 1000 for each Max limit of 200 as mention in website.
I am sure it has more than 1200 record, Can someone please help me how to get all the data for city= Baltimore .
Thanks in advance.

Create a variable to pass the offset value dynamically in the URL and increment the offset value each time by looping in until activity.
Loop the until activity, until the response of the API request is empty.
Example:
#concat('https://npiregistry.cms.hhs.gov/api/?version=2.1&city=baltimore&limit=200&skip=',variables('skip_value'))
You can also use pagination to provide the offset range. Refer this document for more information.

Related

Dynamic Variables in Postman is not coming properly

I am trying to delete users in bulk with Postman. To achieve this operation I have to pass all the user id in append url which is like this -
https://example.com/test/Users/{{id}}
id value I am taking from csv file. Please find below screenshot for more understanding -
And postman is taking value in different way. I guess due to the size of variable it is not considering last 3 numbers
Please help me in this.
Thanks

For snowflakes version 2 API call, how do I retrieve the 2nd partition of the result?

For Snowflakes version 1 API call, we had the concept of pages and page numbers. For Snowflakes version 2 API, we have to provide the partition no for the data partition to be retrieved. I tried to put the partition number in the header, as a parameter and in body of the API, but I still get the first partition as response. Can anyone please help me with this?
The partition number should be passed in the header to get the next partition as detailed here: https://docs.snowflake.com/en/developer-guide/sql-api/handling-responses.html#retrieving-additional-partitions
GET /api/v2/statements/<handle>?partition=1
The
POST https://{your_accountId}.snowflakecomputing.com/api/v2/statements will return a guid called statementHandle.
Plug this statementHandle into the subsequent
GET /api/v2/statements/{statementHandle}?partition=2 and you will receive the data for that specific partition number.

Custom Pagination in datatable

I have a web application in which I get data from my database and show in a datatable. I am facing an issue doing this as the data that I am fetching has too many rows(200 000). So when I query something like select * from table_name;
my application gets stuck.
Is there a way to handle this problem with JavaScript?
I tried pagination but I cannot figure how would i do that as datatable creates pagination for already rendered data?
Is there a way through which I can run my query through pagination at
the backend?
I have come across the same problem when working with mongodb and angularjs. I used server side paging. Since you have huge number of records, You can try using the same approach.
Assuming a case that you are displaying 25 records in one page.
Backend:
Get the total count of the records using COUNT query.
select * from table_name LIMIT 25 OFFSET
${req.query.pageNumber*25} to query limited records based on the page number;
Frontend:
Instead of using datatable, display the data in HTML table it self.
Define buttons for next page and previous page.
Define global variable in the controller/js file for pageNumber.
Increment pageNumber by 1 when next page button is clicked and
decrement that by 1 when prev button is pressed.
use result from COUNT query to put upper limit to pageNumber
variable.(if 200 records are there limit will be 200/25=8).
So basically select * from table_name LIMIT 25 OFFSET
${req.query.pageNumber*25} will limit the number of records to 25. when req.query.pageNumber=1, it will offset first 25records and sends next 25 records. similarly if req.query.pageNumber=2, it will offset first 2*25 records and sends 51-75 records.
There are two ways to handle.
First way - Handling paging in client side
Get all data from database and apply custom paging.
Second way - Handling paging in server side
Every time you want to call in database and get records according to pagesize.
You can use LIMIT and OFFSET constraints for pagination in MySQL. I understand that at a time 2 lacs data makes performance slower. But as you mention that you have to use JS for that. So make it clear that if you wants js as frontend then it is not going to help you. But as you mention that you have a web application, If that application is on Node(as server) then I can suggest you the way, which can help you a lot.
use 2 variables, named var_pageNo and var_limit. Now use the row query of mysql as
select * form <tbl_name> LIMIT var_limit OFFSET (var_pageNo * var_limit);
Do code according to this query. Replace the variable with your desire values. This will make your performance faster, and will fetch the data as per your specified limit.
hope this will helpful.

Linkedin REST API - likes and comments

We are using Linkedin REST API and we need to get the number of likes and comments from owned companies updates. The method get-updates always returns the last 3 likes/comments and also the total is 3, even if you have more than 3. So in order to get all the likes/comments of the updates we have to make a query to each update because that way we get all the likes/comments. But this is not a good method because if I have 100 updates then I have to do 101 api calls and a user has a limit of 700 per day, so they are very easily get depleted. We really find it hard to believe there is no way your API doesn't solve the n+1 problem. So how can it be done?
Thank you!
if you hit this URL -> "https://api.linkedin.com/v1/companies/{id}/company-statistics", provided if you have the id of the company page.
you can get the likes,clicks,impressions,engagement,shares,comments in month break up wise.
For more info
LinkedIn API Company statistics data

Google Web Search API returns only the first 100 result set

Is there a way to search and retrieve all results for a particular query in Google? I want to use Custom Search API, but the starting index of the result set can be 99 at most (http://code.google.com/apis/customsearch/v1/using_rest.html) Which means I can retrieve only the first 100 items. In my case, there are around 4000 items in the result set.
Thanks.
You can retrieve about 1000 results: 100 pages with 10 results each. See: http://code.google.com/apis/customsearch/v1/using_rest.html#query-params
It seems as if you can't go beyond that, though.
UPDATE: I stand corrected. It's only 100.
BTW - The new Google API can return more than 10 results per page, limited by 20 results per page, using num=20
http://www.google.com/cse/docs/resultsxml.html