Retrieve targeted data from an API using JavaScript

My goal is to extract specific information from an API I have access to. The issue I am encountering is that the API limits me to retrieving only 100 lists, and I'm unsure how to retrieve more than that threshold. Below is my code snippet:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
    const api_url =
      "https://data.gov.il/api/3/action/datastore_search?resource_id=8a21d39d-91e3-40db-aca1-f73f7ab1df69";
    async function getData() {
      const response = await fetch(api_url);
      const data = await response.json();
      console.log(data.result.records);
    }
    getData();
      //fetch('https://data.gov.il/api/3/action/datastore_search?resource_id=8a21d39d-91e3-40db-aca1-f73f7ab1df69', {
      //  method: 'GET',
      //  headers: {
      //    'Content-Type': 'application/json'
      //  },
      //  body: JSON.stringify({
      //    
      //  })
      //})
      //  .then(res => {
      //    if (res.ok){
      //      console.log('success')
      //    } else{
      //      console.log('not success')
      //    }
      //  })
      //  .then(data => console.log(data))
    </script>
  </body>
</html>

I've attempted two methods in the code above, but they yield similar outcomes. When examining the data results records, I can see arrays containing information. While I know how to access data for one city, my objective is to retrieve data for multiple cities based on City_name. Is this feasible within the constraints of the API limitation of 100 arrays?

Answer №1

Upon examining the URL provided, I discovered a query parameter that limits the data to 100 entries. To achieve similar results, you can also set a limit by following the example below:

https://data.gov.il/api/3/action/datastore_search?resource_id=8a21d39d-91e3-40db-aca1-f73f7ab1df69&limit=200

In order to optimize your code, I suggest implementing pagination with the use of both limit and offset parameters. By adjusting these values, you can efficiently navigate through the data.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Proper method for positioning text in a line

Trying to recreate the image below, but facing alignment issues with the text in my code. How can I vertically align the text so that they are aligned like in the photo? Flexbox hasn't helped due to varying text lengths causing misalignment. const ...

Issue with retrieving selected radio button value from form in ExtJS. Value not being returned

I have successfully implemented the necessary steps to retrieve the chosen value from my radio button form. .... xtype: 'radiofield', name: 'timespan', id: 'timespan', value: 7, ...

Creating an automated process in Python to retrieve and incorporate the upcoming month's data from an API call

I am currently retrieving data from an API located at the following site: . The code I am using for this operation is as follows: import requests url = "http://prognos.konj.se/PxWeb/api/v1/sv/SenastePrognosen/f06_rantorochvaxelkurser/F0604.px" ...

Dealing with repeated parameters in a URLHow can you handle duplicate

My Ajax select input dynamically changes the URL without refreshing the page. However, I have encountered an issue where repeated parameters stack in the URL when the select input is changed multiple times: [domain]/find.php?cat=1#pricemin=10&pricem ...

Include a fresh attribute to the objects within an array by referencing a distinct array

I have data stored in 2 arrays that contain objects. I want to create a new array by combining information from these two arrays using jQuery and Underscore. These are the structures of the original arrays: var orgArray = [ { "name": "phone", " ...

NodeJS process that combines both client and server functionality

Attempting to develop a test echo server with both client and server in the same node process. When the code is split into two files (server and client), it functions correctly, but when combined into one file, it fails. How can I make it work within a sin ...

Uh-oh! An issue occurred while attempting to assign to the array because it lacks a 'dimnames' attribute

`function(random,starting_probabilities,N)' { StockPosition <- c("SP", "IP", "BP") mysequence <- character() initial_position <- sample(StockPosition, 1, rep=TRUE, prob=starting_probabilities) mysequence[1] <- initial_position ...

Access the JSON file by using a code to open the link

I am currently working on developing an addon and making modifications to some functions within a py file. The specific task at hand involves the following code snippet: def channellist(): return json.loads(openfile('lib.json',pastafinal=o ...

What is the best way to execute a task in Grunt when supplied with a dynamically-generated array of filenames?

Although I am relatively new to using Grunt, I have developed a good understanding of how tasks are installed and executed. Currently, I am successfully running tasks such as minifying js, copying files, and executing jshint. Now, my goal is to implement ...

Importing and exporting JSON information into Cytoscape.js

After coming across this interesting question and answer, I decided to create this JSFiddle to explore further. My objective is to find an effective way to export and import JSON data into cytoscape.js. The approach I took involved using JSON.stringify(c ...

Mistakes within Jquery script

I'm having trouble with this code, can anyone provide some advice or suggestions? Could someone please review this code to see if I made any mistakes? Do you think the issue is related to my use of jQuery? $(document).ready(function showCart(next) { ...

Will the cloning of server components React elements negate their performance advantages?

Recently, I decided to explore React Server Components within NextJS 13, and I encountered a situation where I needed to implement the practice of passing server components as props to a client component. Specifically, I needed to utilize a higher-order co ...

The power of dynamic arrays in C++

I have a question regarding dynamic arrays in C++. As I am still learning the language, I would appreciate it if you could explain things in detail. Is there a way to modify the code below to handle floating-point numbers? #include <iostream> // in ...

Storing an array of JSON objects in separate rows within an SQL database table

I need help with inserting data from an API post request into a MySQL table using Express JS. The JSON array contains multiple objects that I want to fill out the rows in the table, but I can't seem to get it right. Any assistance would be appreciated ...

Adjust the JSON format that is retrieved from an Ajax call

I am working with a JQuery plugin that includes the following code snippet: transformResult: function(response, originalQuery) { } Within this function, I have the task of converting Json data from the originalQuery to the response format: [ { "Id": ...

Incorporate the value of a variable from the .gs file into a personalized HTML sidebar

In my google sheet, I have set up a custom sidebar through scripting. Within this sidebar, I aim to showcase the value from column I in the currently active row. I've successfully created a script that captures and stores the 'I' variable ...

Attempting to showcase PHP print statement within HTML using JSON

I want to showcase two PHP echo messages from a different PHP file on my HTML body page. I aim for the echo message to appear when I click the submit button, without being redirected to the PHP page. To achieve this, I need to establish a connection betwe ...

Employing a series of intervals in order to devise a calculation for the compilation of cell values across multiple sheets

I need to assign an array to a series of ranges. My goal is to loop through each sheet, starting at the 5th one from the left, and select the cell to the right of where it finds the text "Total" in a column. The final step involves aggregating these values ...

Is it possible to include various texts in several spans simultaneously?

I need assistance with the following code. I would like to populate different data in all spans using a single function. <div id="teacher_data"> <p>Name : <span></span></p> <p>Address : <span></span&g ...

Error encountered: iPad3 running on iOS7 has exceeded the localStorage quota, leading to a

Experiencing a puzzling issue that even Google can't seem to solve. I keep getting the QuotaExceededError: DOM Exception 22 on my iPad3 running iOS7.0.4 with Safari 9537.53 (version 7, WebKit 537.51.1). Despite turning off private browsing and trying ...