Jump to content

Using python cURL request

Recommended Posts

Hi y'all.

I'm trying to do something simple, and think I'm close, but getting a little tripped up. Hope someone can help?

I'm trying to use the API to pull in the list of product names that are on my Commerce site. I'm working in Python because of other data processing steps. cURL works fine in Terminal, but I'm not able to pipe the output into a pandas dataframe.

import json
import pandas as pd
import requests
headers = {
    "Authorization": "Bearer xxxxxxxxxxxx",
    "User-Agent": "Get all samples",
    "Content-Type": "application/json",
}

response = requests.get("https://api.squarespace.com/1.0/commerce/products", headers=headers)
response.raise_for_status()
df = pd.DataFrame(response("name"))
 

Can anyone help with this last step? Thanks so much in advance!

 

Link to comment
  • 1 year later...
  • Replies 1
  • Views 1.6k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.