Some data are not accessible in API

Hello, I have made a collection then feed the data and then allowed publi APIs and working fine but when i came bacck and add more data in my collection they are not accessible on API but i can find them in collection.

I have tried to make the API unaccessible then accessible but still no changes any one who can help me?

Could you give some more information like what is the URL you are getting the data from and also how many data do you have?

You can also check the meta object in the bottom of your response.

okay i am using localhost for strapi but if you have time we can try to connect via anyDesk and check the real prolem I am new to this platform as I even dont know how to get that meta obj

I suggest you start from Strapi’s dev docs

When you get to the REST API section you find the Get entries in the Endpoints and basic requests.

If you open a browser and type http://localhost:1337/api/{collection-type_plural} you will receive something like this back (got this from Strapi docs)

{
  "data": [
    {
      "id": 1,
      "attributes": {
        "title": "Restaurant A",
        "description": "Restaurant A's description"
      }
    },
    {
      "id": 2,
      "attributes": {
        "title": "Restaurant B",
        "description": "Restaurant B's description"
      },
      ...
    },
  ],
  "meta": {
      "pagination": {
         "page": 1,
         "pageSize": 25,
         "pageCount": 1,
         "total": 2,
      }
  }
}

In the meta there are pageSize and total keys. pageSize: 25 means that the API will return only 25 results back, and total is the number of your total data inside your collection.

Now, if you have more than 25 items in your collection, then you will receive the first 25 and then you will need to ask for the second page in order to get the next 25 items, that is from item number 25 through 50.

I hope I helped a bit :slight_smile:

1 Like
"meta":{"pagination":{"page":1,"pageSize":25,"pageCount":4,"total":91}}

That is my data info how to get data from other pages

I suggest you check the Pagination section in Strapi’s documentation.

There are two ways to implement what you want based on your total data. Either change the page and get responses per 25, or change the pageSize and get all results at once.

page option: you want something like this http://localhost:1337/api/{collection-type_plural}?pagination[page]=X where X is the number of the page, 1,2,3…N

pageSize option: you want something like this http://localhost:1337/api/{collection-type_plural}?pagination[page]=1&pagination[pageSize]=Y. Where Y is the number of results you want to get in the response, 25, 50, 91, 100 etc. Please note that Strapi’s default maximum limit for pageSize is 100.

Cheers

1 Like

cheers, thanks a lot but dont they have away to just pull out all data at one go as i am working on so many data and starting to think this is not good or is there a best reason for them to do it like this

Pagination is used for optimization and to save bandwith.

You can change the default maximum limit to something bigger than 100 by overwritting the maxLimit in ./config/api.js

More details → API configuration | Strapi Documentation

Happy I could help!