1

If I make the following GET request to the GitHub API, I get about 58 entries:

https://api.github.com/search/repositories?&per_page=250&sort=updated&order=asc&q=%22github-octocat%22

However, the following with any date parameters return 0 entries:

Created since date: ( created:>=2010-09-01 )

https://api.github.com/search/repositories?&per_page=250&sort=updated&order=asc&q=%22github-octocat+created:>=2010-09-01%22

Date range: ( created:2012-08-13..2020-08-14 )

https://api.github.com/search/repositories?&per_page=250&sort=updated&order=asc&q=%22github-octocat+created:2012-08-13..2020-08-14%22

In the GitHub docs, under the section Constructing a search query, the syntax is outlined as such:

SEARCH_KEYWORD_1 SEARCH_KEYWORD_N QUALIFIER_1 QUALIFIER_N

Thei GitHub docs at Search by when a repository was created or last updated outlines date formats like the two above, and Query for values between a range outlines valid combinations of them. I suspect these examples are not meant for this use, as the examples use URLs intended for browsers, such as https://github.com/search?q=case+pushed%3A%3E%3D2013-03-06+fork%3Aonly&type=Repositories, instead of api.github.com, which is confusing too.

I'm trying to apply the patterns shown in the following resources in order to get a range of dates filter:

Any pointers greatly appreciated.

Eamon Bohan
  • 522
  • 2
  • 8
  • 22
  • 1
    Are you using a proper query parameter serializer? I'd expect more characters in your url to be urlencoded. – Evert Dec 31 '20 at 05:40
  • Hi @Evert—I am not sure what that would be in this case. Do you have any pointers? Thanks – Eamon Bohan Dec 31 '20 at 07:31
  • Well, it depends on your language. So share your code, maybe someone can help. – Evert Dec 31 '20 at 07:34
  • @Evert, I am actually just doing a combination of GET requests using Postman as a testing service, and also replicating these in the browser, where I can't attach authentication tokens when entering a URL. I will be using a JS framework when I understand what the syntax is though. – Eamon Bohan Dec 31 '20 at 10:00
  • 1
    Then look up how to urlencode variables in urls. Shouldn't be too hard to find! – Evert Dec 31 '20 at 19:55

1 Answers1

1

Even though the GitHub docs outlines the syntax as such:

SEARCH_KEYWORD_1 SEARCH_KEYWORD_N QUALIFIER_1 QUALIFIER_N

the parameters for date or similar, are not valid unless placed outside the q parameter. Instead of including date qualifier inside of the double quotes (shown as %22 below):

q=%22mysearch+pushed%3A2017-09-01..2020-10-01+sort:updated%22

Pull them out, and add them after the closing quote of the q parameter:

q=%22mystring%22+pushed%3A2017-09-01..2020-10-01+sort:updated
Eamon Bohan
  • 522
  • 2
  • 8
  • 22