API requests and the ISS-pass API

Screen Link:
[Learn data science with Python and R projects](https://ISS Pass Problem in API class (problem 4))

My Code:
In problem 4:

response=requests.get("http://api.open-notify.org/iss-pass.json")
status_code=response.status_code

What I expected to happen:
I’m working on the first of the two links shared above. I’ve got a couple of lines of code written that are identical to the code in the previous problem., other than the API “iss-now” versus “iss-pass”. The previous problem gave me a status code of 200 for the iss-now API. For the ISS-pass API, I expected the same prior to running the program.

What actually happened:
I received a status code of 400 for the ISS-pass API. At this URL, I see the ISS-pass API no longer exists.
[Open Notify -- API Doc | ISS Pass Times](https://ISS Pass API)
I can see from the feedback given by the grader that I should have received a 404 error, and that’s consistent with what I see on the web. I’m not sure why I’m getting a 400 error for an API that doesn’t exist.

status code (int <class 'int'>)
- actual + expected
- 400
+ 404

I just bought data quest an hour or two ago and this is literally my second problem in this API class. I have an extensive background in physics and astronomy research and have spent a little time preparing for data science with other services, but I have never been successful with requests or json in general before. I would really love some help getting past this so I can be successful in this class and pick up the material I need to be able to do data science.

2 Likes

It’s probably because screen 4 is meant to show the students the mistake of not putting .json at the end. In a way, you’re ahead of the curve because screen 5 will show the correct url with .json appended.

Another thing to note that if you check the variable response, it’s not an actual response from Open Notify; it’s just a mock. I believe Dataquest uses a mock requests which returns a pre-written response, rather than an actual GET request to Open Notify. It’s probably because they are aware of the possibility that an API can be removed (as you’ve seen from the link) one day.

Edit: Reading your other post, I believe you’re aware of the mock request, but I’ll leave my answer up in case anyone is perplexed about the issue.

Related:

1 Like

I’m completely new to this program. Does that mean I’ve already failed the course? (Somehow, this seems a bit absurd for a single typo on literally the first problem I have to type in myself).

Edit: completely annoyed and not 100% confident in this software so far but not sure I want to quit yet. It certainly does seem unfair if a typo on your first problem could prevent a certificate. I hope I’m reading this wrong. But I do need to learn APIs, visualization, and machine learning either way, whether I get a certificate or not.

2 Likes

I don’t think you failed. It’s more that you were able to think a step ahead of what Dataquest is trying to teach which can clash against a platform dedicated to teaching students step by step.

The grade checker can be rigid, so sometimes when they want to intentionally teach you about certain mistakes, you’ll have to intentionally make those mistakes even when you know the answers. This is emblematic of courses that use automated answer checking.

The guided projects will probably be more to your liking.

1 Like

@sdorsher, it’s me again, and with the same post :wink:

This time, please check points 2 and 3 and follow the corresponding steps.

I’m not sure that’s the issue here? Is there actually a reason a request to a site that doesn’t exist would give a 400 error rather than a 404 error? I’m not sure this is a technical issue. I might not be understanding. Can someone please explain? My output was 400. The desired output was 404. It’s only one line of code.

2 Likes

My hunch is considering the context of the time the instruction was written, the API does exist; so, the mock request — some sort of replica of the original API — was written under the presumption that it still exists i.e. they mocked the actual API when it existed which returns a 400 for the correct endpoint, and 404 for an incorrect endpoint.

In other words, they’re not mocking the API based on its current state which as you observed doesn’t exist anymore and should return 404 for every endpoints or requests.

Though, maybe it’s better for DQ to replace the inactive API example with a working one instead to remove the confusion.

1 Like

I switched to the Data Science track in the mean time (and am currently at 97% on examining conflicts on trying to install spyder after 48 hours, “conda_content_trust”…) but in the mean time, do you know how I can find any info about what I might have missed in the request given that the documentation no longer exists?

I know I initially made a bad request by ending it without json. Is it something peculiar to requests that if you make one bad request, the server rejects you thereafter?

Or do I need to supply some second argument or some other line of code? How would I know what that is without documentation?

2 Likes

I’m not too sure either.

In cases like these, the best option is to possibly just follow the instruction exactly rather than looking for the documentation for an API that doesn’t exist. Maybe I’m being a bit presumptuous, but your time is precious and I think it’s best served by finishing the exercise quickly and move on to something else e.g. make an actual GET request to an active API of your own choosing in Jupyter or other IDEs.

With that said, here’s an archive of the API documentation: Open Notify -- API Doc | ISS Pass Times

1 Like

It’s just really really really weird when the grader gives you feedback that makes it unclear whether you’ve ultimately done the problem correctly and how to fix it. I guess if I made a mistake it’s fine to move on… I do struggle with reading the instructions exactly. But I’d love to know how to do the coding correctly, and I’m legitimately confused.

2 Likes

Yeah, it can be confusing at times. Hopefully, the Dataquest team can improve the grader to lessen the potential confusion.

1 Like

And furthermore, although I don’t currently have python updated-- it’s important that any solution I learn here ACTUALLY WORKS IN PYTHON. And moreover, that I don’t become confused about solutions that ACTUALLY WORK IN PYTHON. I spent some time exploring other solutions I already know or could quickly look up based on my memory in the Prison Break project because I wanted to have more fun than I was having. It worked. That was great! I learned something, whereas otherwise I wouldn’t have. I’m sincerely hoping to make requests work, since I’ve greatly greatly struggled with that in my past learning experiences. Hopefully later problems will help clarify this when I go back to the course later!!!

2 Likes

Once your Python is updated, maybe you can start your own project specifically focused on learning how requests work. This API is quite popular: Hacker News API Docs.

1 Like

Err… I don’t think I’m there yet. Need a class. I have previously tried a project through the Data Incubator, remotely in 2018. I couldn’t even get their code to run, much less write my own. That’s why I’m a bit concerned about it…

2 Likes

Ah, I see.

Thank you for clarifying that. I’m just throwing out ideas.

Though, if one day you feel inclined to start an API project of your own, feel free to post the issues you encounter on this forum.

I’m not an API expert by any means, but it would be interesting to see other people’s API project.

1 Like

Speaking of which, what a waste of $5000 Data Incubator was. Their code didn’t run, and there was NO remote support for that. Don’t fall for that stuff. The google certificate on Coursera has hidden costs of $500/month with Big Query, but seems legitimate other than that. I’m HOPING this path will work out better. It seems really great so far, even if I do have to retake some stuff I’d rather not, and even if I am struggling with requests, as I have before. :frowning:

2 Likes

Sorry to hear about your bad experiences with other courses.

Dataquest has been great for me so far, and I hope your experience here would be better than what you experienced in the past.

Anyhow, I wish you the best in your learning whether it’s here or anywhere you find yourself in the future.

2 Likes

Hey, my appologies. It is definitely possible there is a solution here, but I can’t mark one because I switched learning paths to Data Science Career path and can’t test one right now! This may all be very helpful in the future! Thanks so much for everyone’s answers!

2 Likes