GitHub API search query for non-null parameters? - github

I'm trying to search for the top GitHub users by # of non-forked repos, that have a public email address. When using the /search/users endpoint, it seems you must pass a query (q= parameter) and when I tried the following, it returned one result:
https://api.github.com/search/users?q=%40&in:email&sort=repositories&order=desc&type=user
I know my syntax is off by the documentation (here and here) is not very helpful when constructing the URI.
Is there a way to specify that I want to select those users with the most non-forked repos and with non-null/empty email fields?

Is there a way to specify that I want to select those users with the most non-forked repos and with non-null/empty email fields?
No, not possible currently using the Search API.

Related

Submitting a SPARQL query with variable binding to GraphDB REST API

I am trying to submit a SPARQL query to a local repository on Ontotext GraphDB via its REST API. According to the documentation, one of the query params is also $<varname> which specifies variable bindings.
Suppose we have a repository called testrepo that contains customers, each of whom has a unique customerID. Submitting the following query:
PREFIX : <http://www.example.com/>
SELECT * WHERE {
?customer a :Customer ;
:hasID ?customerID .
}
as a GET request with the respective variable binding customerID = "123" unfortunately retrieves all the customers and not the specific one.
Here is the request:
http://localhost:7200/repositories/testrepo?query=PREFIX%20%3A%20%3Chttp%3A%2F%2Fwww.example.com%2F%3E%0ASELECT%20*%20WHERE%20%7B%0A%09%3Fcustomer%20a%20%3ACustomer%20%3B%0A%20%20%20%20%20%20%20%20%20%20%20%3AhasID%20%3FcustomerID%20.%0A%7D%20&customerID="123"
So, what am I doing wrong?
SOLVED: As specified by UninformedUser and Joshua Taylor, I should have added a $ in front of the param name.
The correct request is the following:
http://localhost:7200/repositories/testrepo?query=PREFIX%20%3A%20%3Chttp%3A%2F%2Fwww.example.com%2F%3E%0ASELECT%20*%20WHERE%20%7B%0A%09%3Fcustomer%20a%20%3ACustomer%20%3B%0A%20%20%20%20%20%20%20%20%20%20%20%3AhasID%20%3FcustomerID%20.%0A%7D%20&$customerID="123"

How can i search all github repositories by file extension using github API

I want to search all repositories that contain the extension *.xcodeproj
When i query at my browser: https://github.com/search?q=extension%3Axcodeproj+language%3ASwift&type=repositories, it returns: 427,768 results.
But when I query the same using github API, query: https://api.github.com/search/repositories?q=extension:xcodeproj+language:Swift, it returns 0 results.
I also tried: https://api.github.com/search/code?q=extension:xcodeproj+language:Swift, still same result.
Not sure what's going wrong there.
Edit: Yes I am using the PAT token to bypass the rate limit and code search (without repo+org+owner) constraint.
The Github API query should be the following. You need to use & to add search criteria.
https://api.github.com/search/repositories?q=extension:xcodeproj&language:Swift

Proper multi-id syntax when using the custom_file_ids[] query parameter for the CLIO API "contacts" endpoint

What is the correct API syntax for using the custom_file_ids[] query parameter to specify multiple fields (but not all) in the CLIO API contacts result set? I need to specify multiple custom fields. I can get it to work for a single field, but not multiple fields at the same time.
Specifically, how do I specify and delimit the multiple fields? I have tried the following:
custom_file_ids[]=1234567,2345678
custom_file_ids[]=[1234567,2345678]
custom_file_ids[]=(1234567,2345678)
custom_file_ids[]={1234567,2345678}
custom_file_ids[]=1234567:2345678
The API documentation at https://app.clio.com/api/v4/documentation is silent on the list syntax that it expects.
Below is one specific API call I tried (both the actual URL-encoded call, and a decoded one for clarity) using a simple comma-delimited list, but which only returns custom field data for the first ID in the list--not the second. If I enclose the ID list in any kind of brackets (per above), the endpoint returns a 404 error.
https://app.clio.com/api/v4/contacts?custom_field_ids[]=1234567%2C2345678&custom_field_values[4529224]=true&fields=id%2Cname%2Cprimary_address%2Cprimary_work_address%2Cis_client%2Ctype%2C%20primary_email_address%2Cprimary_phone_number%2Ccustom_field_values%7Bid%2Cfield_type%2Cfield_name%2Cvalue%2Ccustom_field%7D
https://app.clio.com/api/v4/contacts?custom_field_ids[]=1234567,2345678&custom_field_values[4529224]=true&fields=id,name,primary_address,primary_work_address,is_client,type,primary_email_address,primary_phone_number,custom_field_values{id,field_type,field_name,value,custom_field}
Try:
custom_file_ids[]=1234567&custom_file_ids[]=2345678
I was able to do this with Contacts Custom Fields by putting custom_field_id[] on the URL as many times as you have IDs.
I hope this helps.

Select * for Github GraphQL Search

One of the advantage of Github Search v4 (GraphQL) over v3 is that it can selectively pick the fields that we want, instead of always getting them all. However, the problem I'm facing now is how to get certain fields.
I tried the online help but it is more convolution to me than helpful. Till now, I'm still unable to find the fields for size, score and open issues for the returned repository(ies).
That's why I'm wondering if there is a way to get them all, like Select * in SQL. Thx.
GraphQL requires that when requesting a field that you also request a selection set for that field (one or more fields belonging to that field's type), unless the field resolves to a scalar like a string or number. That means unfortunately there is no syntax for "get all available fields" -- you always have to specify the fields you want the server to return.
Outside of perusing the docs, there's two additional ways you can get a better picture of the fields that are available. One is the GraphQL API Explorer, which lets you try out queries in real time. It's just a GraphiQL interface, which means when you're composing the query, you can trigger the autocomplete feature by pressing Shift+Space or Alt+Space to see a list of available fields.
If you want to look up the fields for a specific type, you can also just ask GraphQL :)
query{
__type(name:"Repository") {
fields {
name
description
type {
kind
name
description
}
args {
name
description
type {
kind
name
description
}
defaultValue
}
}
}
}
Short Answer: No, by design.
GraphQL was designed to have the client explicitly define the data required, leading to one of the primary benefits of GraphQL, which is preventing over fetching.
Technically you can use GraphQL fragments somewhere in your application for every field type, but if you don't know which fields you are trying to get it wouldn't help you.

Query items user was mentioned in

Is there a way to query work items where a user was mentioned? I am able to receive 'hard-coded' results by querying for
"History"-"Contains word"-"\#Username",
but I want a generic version, which works for all users. (Opposed to writing one query for every user)
Use this predicate:
Field: "ID"
Operator: "In"
Value: "#RecentMentions"
This automatically filters for work items, where current user has been mentioned.
I found it in predefined filter "Mentioned" in "Work Items" section. If you click on "Open in Queries" button, you will get a query with above filter. (This section can even remove the need for that query...)
Note: at present time, works only in VSTS.
https://{org}.visualstudio.com/{project}/_workitems/mentioned/
This would achieve the same result.
There is no way to achieve this by work item query directly just as starain mentioned. You can create a custom hub or custom widget by using VSTS Extension to show these information in web portal.
You can’t achieve that through work item query directly, you could build a app to retrieve data through REST API (https://www.visualstudio.com/en-us/docs/integrate/api/wit/wiql), change query text according different conditions (e.g. users)
Your query should be something like this
Select Id,Title From WorkItems Where ID IN (#RecentMentions) order by [System.ChangedDate] desc
here is the reference for rest of the macro's available in ADO rest API.
https://learn.microsoft.com/en-us/azure/devops/boards/queries/query-operators-variables?view=azure-devops