Jump to content

Recommended Posts

Posted

I'm using Python's request library to query the API.  The documentation doesn't show what a paramatized filtering url would look like.

For example,

https://source-docs.blesta.com/class-Services.html#_getList

The filter variable is supposed to be passed as an array.

 

#getList( integer $client_id = null, string $status = 'active', integer $page = 1, array $order_by = ['date_added' => 'DESC'], boolean $children = true, array $filters = []  )

Returns a list of services for the given client and status

 

Using python requests, that would be done like this....

def services_getAllByClient():
     data = request(
          'services/', 'getlist', blesta_format, params={'client_id': 741, 'filters': ['package_id', 112]}
     )
     print(data.url)

 

>>> app.services_getAllByClient()
https://[myblestainstall.com]/api/services/getlist.json?client_id=741&filters=package_id&filters=112

It's not filtering....   What would correct paramaratized files look like?

 

  • 1 year later...
Posted

An example of an API URL with a filter would look like this:

 
arduino
https://api.example.com/items?category=books&price_min=10&price_max=50

In this example:

  • category=books filters items by category.
  • price_min=10 filters items with a price of at least 10.
  • price_max=50 filters items with a price no higher than 50.

Filters are typically added as query parameters in the URL after the ?.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...