How to use the github API with OR queries within a repo? What is the right syntax/library? #140529
Replies: 3 comments
-
Hei, The error occurs because the GitHub API search syntax is different from the UI. The API doesn't support complex queries with parentheses for logical grouping (like AND, OR). To solve this, break the query into multiple requests or try simpler combinations in one request. Here’s an adjusted query: query = 'repo:open-telemetry/opentelemetry-demo client OR repo:open-telemetry/opentelemetry-demo import' This will search for client or import within the same repository. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the response. Right now, I'm doing the multiple requests thing to get it to work. But I need to reduce the number of requests to send out to the API, hence why this attempt. The adjusted query did not work either. |
Beta Was this translation helpful? Give feedback.
-
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
I'm trying to use the github API to do a OR query within a repo.
Trying to do a programmatic replication of this query from the UI :
repo:open-telemetry/opentelemetry-demo AND (client OR import)
I can do it on the UI like so: https://github.com/search?q=repo%3Aopen-telemetry%2Fopentelemetry-demo+AND+%28client+OR+import%29&type=code
Programmatically, I try to do it like this:
and it outputs:
https://api.github.com/search/code?q=repo%3Aopen-telemetry%2Fopentelemetry-demo+AND+%28client+OR+import%29
Beta Was this translation helpful? Give feedback.
All reactions