This talk is primarily for web developers. It's about understanding how to write an API client that is testable and sensible without being more opinionated than necessary.
A Python-centric talk given at PyTennessee 2015 in Nashville, TN.
Data or Resources? • If you think about everything as a resource, then shouldn’t it have the same methods? • Or is it data and the API is just providing some • You’re not obliged to represent 1:1
Second, we wanted to give you a heads up that we're announcing a new feature soon -- additional fields. This will allow people to get congressional districts, state legislative districts, timezones, and school districts with a forward or reverse lookup. We are looking to add more additional fields in the future (namely Census data).
futures = [ session.post(url, data=json.dumps(data_chunk)) for data_chunk in chunker(data, 100) ]
while not all([f.done() for f in futures]): continue
status_codes = {} responses = [f.result() for f in futures]
addresses = AddressCollection([]) for response in responses: if response.status_code not in status_codes.keys(): status_codes[response.status_code] = 1 else: status_codes[response.status_code] += 1
if response.status_code == 200: addresses[0:0] = AddressCollection(response.json())
• Create the client *first* then Django integration is a bonus. • Mapping models to a distant API. • It’ll be easier for you to maintain and test • Easier for other people to use for other things