HunterLiu
HunterLiu

Reputation: 801

Is there a way to search for an edx course using their API?

I have an edX client ID and secret ID, and I'm able to get the list of all edX online courses, but I want to be able to search through all of the edX courses with a query string like "robotics". (Unlike this question, I already understand how to get the list of courses, so this is not a duplicate question...) I tried

import requests

# I also tried with search_query instead of search
edx_course_search_response = requests.get('https://api.edx.org/catalog/v1/catalogs/'+edx_course_catalog_id+'/courses/'+"?search=robotics", headers=headers)

I know the catalog id and headers information is correct because I can get the list of edX courses. Unfortunately, this does not work and instead returns the first 20 online courses in edX's database as usual.

If I can't, I think I'm going to use whoosh.

Upvotes: 1

Views: 358

Answers (1)

QHarr
QHarr

Reputation: 84465

I don't think so.

query is a response value from this endpoint: GET /catalog/v1/catalogs/{id}/. The endpoint for retrieving info about a specific catalog. It is not a user passed parameter. The user parameter is catalog id.

You might use this endpoint: /catalog/v1/catalogs/{id}/courses/

That endpoint, as mentioned in comments has an answer covering pagination here. You could then filter the returned dataset with python according to your query term. The results array in response values from that endpoint has fields such as short description/long description/title which might be useful to target.

Upvotes: 0

Related Questions