Skip to content
Advertisement

Tag: api

Return JSON object with a “header”

I have an API, where I need to return data. I want to make a “header”, where I specify the amount of tutors, the call returned. My current function looks like this: This is an example, of the response. ] I’d like to add a header, that specifies the amount of tutors/arrays that the response returned. So it would be

How to add data to Many-To-Many field in Django DRF

I’m new to Django DRF, trying to have a sports school project done. I have a model for coaches, classes and students. Here is a stripped version to keep it simple and easy: In order to list/add students to the class, I’m using the following serializer: Getting the data is working ok. Also, adding a coach is working fine, what

Why airflow is returning error while requesting Rest API?

I have a python code which is requesting a Rest API. The API has more than 5000+ pages so i tried to request it but always i am getting error at 2000th request. The error is: “df = pd.json_normalize(json_data[“items”]) KeyError: ‘items'” How can i solve this problem ? P.S. In locally, the code is working clearly. Answer I found a

yfinance not working – receiving json.decoder.JSONDecodeError

I am scraping stock market data from yfinance. My code worked perfectly during the last weeks. For some reason, now I am receiving the following error: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) when executing: I have read about this error on Stack Overflow, but no one had an appropriate solution to fix the problem. I am wondering

Syntax for nested dictionaries in Python

I’m developing Python scripts for the automated grading of assignments using CanvasAPI, an API wrapper in Python for the Canvas learning management platform. In studying the documentation, I can successfully issue curl commands in Python for a few parameters. For example, this conversion below is for uploading rubric information for a single submission: Curl command per the Canvas API docs:

How to parse a list of dictionaries in Python 3

I’m using python(requests) to query an API. The JSON response is list of dictionaries, like below: I’d like to extract 1 field (Identifier) as a list for further analysis (count, min, max, etc.) but I’m having a hard time figuring out how to do this. Answer Python has a syntax feature called “list comprehensions”, and you can do something like:

Advertisement