Code Monkey home page Code Monkey logo

Comments (5)

syrnick avatar syrnick commented on May 23, 2024

It fetches only one page of records(that is limited to 100 records). The api call returns an "offset" to fetch the next page. See the forEach implementation in the JS client: https://github.com/Airtable/airtable.js/blob/master/lib/table.js#L73

from airtable.py.

MikeVaughanG avatar MikeVaughanG commented on May 23, 2024

Is there a way to increase this page limit? I think I might be missing something.
Pardon me, I'm new to this.

Im using this code to return a list of the records on my table, using the 'Name' field as the keys, and a dict as a value for each one.

def get_clientlist():

    at = airtable.Airtable('appua4wbLWf65hiXG/', 'my_api_key')
    clients = at.get('Clients')['records']
    client_list = {}
    for item in clients:
        name = item['fields']['Name']

        client_list[name] = item['fields']

return client_list

from airtable.py.

nicocanali avatar nicocanali commented on May 23, 2024

As @syrnick suggested, you could do something like using offset:

def get_clientlist():
    at = airtable.Airtable('appua4wbLWf65hiXG/', 'my_api_key')
    client_list = []
    clients = at.get('Clients')
    offset = clients.get('offset')
    client_list.append(clients['records'])
    while offset:
        clients = at.get('Clients', offset=offset)
        offset = client.get('offset')
        client_list.append(clients['records'])
    return client_list

You could also do everything in a while loop, problem being that offset must be a string with this version.

from airtable.py.

MikeVaughanG avatar MikeVaughanG commented on May 23, 2024

Thanks a ton, guys. I got it working now.

Sorry for the late reply.

And since this isn't technically an 'issue', I'll close it.

from airtable.py.

ohiosonia avatar ohiosonia commented on May 23, 2024

@MikeVaughanG how did you print out client_list? Using your code above, I added two lines at the bottom:

from airtable.airtable import Airtable
from airtable import airtable
import requests

def get_clientlist():
    at = airtable.Airtable('BASE ID', 'API KEY')
    client_list = []
    clients = at.get('Project%20Tracker')
    offset = clients.get('offset')
    client_list.append(clients['records'])
    while offset:
        clients = at.get('Project%20Tracker', offset=offset)
        offset = client.get('offset')
        client_list.append(clients['records'])
    return client_list

a = get_clientlist() 
print a

However, I'm getting the following error:

  File "airtable_test.py", line 22, in <module>
    a = get_clientlist()
  File "airtable_test.py", line 17, in get_clientlist
    clients = at.get('Project%20Tracker', offset=offset)
  File "/usr/local/lib/python2.7/site-packages/airtable/airtable.py", line 76, in get
    if offset and check_string(offset):
  File "/usr/local/lib/python2.7/site-packages/airtable/airtable.py", line 31, in check_string
    raise IsNotString('Expected a string')
airtable.airtable.IsNotString: Expected a string```

from airtable.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.