Jonny Andino

Web Developer
Game Developer
Musician

Adventures in freelance - Got Games?

Why did I decide to write an API for a client in a language I’ve never built anything with before? Isn’t that irresponsible? Well… Yes, but I’m glad I did anyway! Here’s what I learned. Look at some code.

def get_products(self):
    print('retrieving products list...')
    response = json.loads(requests.get(
        f"https://api.squarespace.com/{self.api_version}/commerce/products",
        headers = self.headers
    ).text)
    products = response['products']

    while response['pagination']['hasNextPage']:
        # time.sleep(1)
        response = json.loads(requests.get(
            f"https://api.squarespace.com/{self.api_version}/commerce/products?cursor={response['pagination']['nextPageCursor']}",
            headers=self.headers
        ).text)

        products = products + response['products']
    
    return products

Background art: Last Night Sky by: BisBiswas

© Jonny Andino - bow682@gmail.com