Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array query params handling #380

Open
kryvel opened this issue Jan 12, 2024 · 2 comments
Open

Array query params handling #380

kryvel opened this issue Jan 12, 2024 · 2 comments

Comments

@kryvel
Copy link

kryvel commented Jan 12, 2024

Hello,

I would like to discuss the handling of GET query parameters in the OpenSanctions API.

After a thorough debugging, I have identified the reason why my query is not functioning as expected. It is a simple matching request with excluded datasets, as shown below:

Original Query:

https://api.opensanctions.org/match/sanctions?exclude_dataset[]=ua_nabc_sanctions&exclude_dataset[]=ua_nsdc_sanctions&exclude_dataset[]=ua_sfms_blacklist

However, the API expects the following syntax for array parameters:

Expected Query Syntax:

?exclude_dataset=ua_nabc_sanctions&exclude_dataset=ua_nsdc_sanctions&exclude_dataset=ua_sfms_blacklist

In my opinion, this approach seems a bit unconventional. Typically, arrays in GET queries are passed in one of the following common ways:

  1. Using square brackets for each parameter value:
param[]=value1&param[]=value2...
  1. Comma-separated values for a single parameter:
param=value1,value2...

Is this behavior the intended and expected behavior for the OpenSanctions API?

Thank you for your clarification.

@pudo
Copy link
Member

pudo commented Jan 12, 2024

Hey! I think there may be a weird programming language idiosyncrasy here: Python likes the straight variant, whereas PHP and Ruby seem to parse the square bracket syntax more easily. Since I'm not super keen on breaking the API, perhaps we could look into defining x[] as an alias for the x variant?

@kryvel
Copy link
Author

kryvel commented Jan 12, 2024

Hi, Friedrich
I believe an alias would be more than enough in this case. However, it would be great to mention such behaviours in the documentation within the parameter description, so users won't be confused by the query syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants