Khan / khan-api

Documentation for (and examples of) using the Khan Academy API
http://www.khanacademy.org
377 stars 75 forks source link

Dcoument tags argument to /api/v1/exercises better #116

Open ThomasKranitsas opened 7 years ago

ThomasKranitsas commented 7 years ago

When I make a call to /api/v1/exercises without pass any tag in the query the endpoint works fine but if I pass any tag e.g.: /api/v1/exercises?tags=math I get an empty array as result ([]).

No matter what the tag or how many tags I'll use, the result is always an empty array.

I noticed that the tag attribute in all objects returned from the /api/v1/exercises is an empty array, maybe this is why the api returns an empty array when I pass any query.

ThomasKranitsas commented 7 years ago

FYI I use POSTMAN to make calls because the API explorer gives me 500 INTERVAL ERROR as mentioned in #115

rootelement commented 7 years ago

Anything on this issue? We're unable to use this API without this feature.

benjaminjkraft commented 7 years ago

It seems like this field was never working correctly for exercises in our newer exercise framework, and the only change is that we've migrated all exercises over. I'll file an internal bug, but I'm not sure how soon we'll get to it. You may need to find a workaround, such as by using /api/v1/assessment_items/tags, and using the returned tag ID/name pairs to do the filtering on the client.

benjaminjkraft commented 7 years ago

Ah, it looks like there is in fact a better way. If you get /api/v1/assessment_items/tags, and find your desired tag in there, you can use the "id" field from that response as a tag to filter on. I'll leave this issue open, to improve our documentation to explain this.

rootelement commented 7 years ago

I have a couple clarifying questions...

  1. The /api/v1/assessment_items/tags is an endpoint not documented in your api explorer correct?
  2. The IDs that come back from those tags look like this: ag5zfmtoYW4tYWNhZGVteXIxCxIRQXNzZXNzbWVudEl0ZW1UYWciATAMCxIRQXNzZXNzbWVudEl0ZW1UYWcYmbU_DA
  3. You're recommending we query the /exercises endpoint, get back all exercises (24mb Compressed Response) and front-end string match on those IDs?

I don't think that's at all viable... This is for a project for GE Foundation and College for Every Student who wanted to surface Khan courses to the students in the STEM program. Is there some way we can connect outside of GitHub Issues to see if we can move this forward?

The site is http://brilliantcareerlab.org

cc: @ThomasKranitsas

benjaminjkraft commented 7 years ago
  1. Correct. I've made an internal issue to document it.
  2. Correct.
  3. Sorry, to be clearer -- that was my first suggestion, but then I realized you can also pass those to /api/v1/exercises?tags=ag5z..., and it should do the same filtering.

I'll follow up internally on Monday and see if there's a good person with whom to put you in contact.

benjaminjkraft commented 7 years ago

Also, @rootelement, I'm benkraft@khanacademy.org -- if you send me an email I can put you in contact with appropriate folks on our team.

krisives commented 7 years ago

@benjaminjkraft Thank you for the details about this situation. We are running into the same issue as we have a student that has a very large history of exercises which when we use the API throws a 500 because the result is too big. I have read your suggestion for filtering on tags, but this is not viable for us since we need to check all exercise activity in the last 24 hours in bulk.

The first thing I did was load the khanacademy.org website itself to see how it does this. I then noticed it does not use the v1 API but instead uses an "internal" API which has different tokens and keys from what I can tell. This internal API being used is called "progress" and it passes date stamps as "dt_start" allowing it to filter. I tried passing these to the v1 API and had no luck. From my experience other than tag there is no way to filter the result set coming back from the v1 exercises endpoint. If we had any ability to filter based on time or limit or pagination we could solve all our problems.

I noticed others discussing POSTMAN a third party commercial service. I am not familiar with this, but I wanted to know if Khan Academy API works any differently through this service. Does Khan affiliate with or provide different access via POSTMAN that would solve this, or are they just a third party that does the same OAuth API requests on our behalf? I understand if you are not familiar with POSTMAN but thought I would ask anyway since we need a solution.

benjaminjkraft commented 7 years ago

@krisives that sounds like a different issue -- the problem reported here is about the tags argument not working as documented. If you could file a separate issue to discuss, that would help us investigate.

You are welcome to use our internal APIs as well as documented ones, but keep in mind that we don't generally provide support for them and they can change at any time. If you mention the specific endpoint you're using, we may be able to post at least a little unofficial documentation.

We're not affiliated with POSTMAN, so they would just be a third party that would do the same requests on your behalf.