Low-level API

Low-level API interface to Raindrop, no application semantics, mostly core HTTP verbs.

Except for instantiating, methods in this class are not intended for direct use, they serve as the underlying HTTPS abstraction layer for calls available for the Core Classes, ie. Collection, Raindrop etc.

class raindropiopy.api.API(token: str, client_id: str | None = None, client_secret: str | None = None, token_type: str = 'Bearer')

Bases: object

Provides communication to the Raindrop.io API server.

Parameters:
  • token – Either a string representing a valid RaindropIO Token. This is either a TEST_TOKEN or a CLIENT token for use in OAuth in which case the client_id and client_secret must also be provided.

  • token_type – Token type to be used on behalf of an oAuth connection.

Examples

Can either be used directly as a context manager:

>>> api = API(token="yourTestTokenFromRaindropIO"):
>>> collections = Collection.get_collections(api)
>>> # ...

or

>>> with API(token="yourTestTokenFromRaindropIO") as api:
>>>     user = User.get(api)
>>>     # ...
close() None

Close an existing Raindrop connection.

Safe to call even if a new session hasn’t been created yet.

delete(url: str, json: Any = None) Response

Low-level call to perform a DELETE method against our present connection.

Parameters:
  • url – The url to send the DELETE request to.

  • json – JSON object to be sent.

Returns:

requests.Response object.

get(url: str, params: dict[Any, Any] | None = None) Response

Send a GET request.

Parameters:
  • url – The url to send the request to.

  • params – Optional dictionary of payload to be sent for the Request.

Returns:

requests.Response object.

open() None

Open a new connection to Raindrop.

If there’s an existing connection already, it’ll be closed first.

post(url: str, json: Any = None) Response

Low-level call to perform a POST method against our present connection.

Parameters:
  • url – The url to send the POST request to.

  • json – JSON object to be sent.

Returns:

requests.Response object.

put(url: str, json: Any = None) Response

Low-level call to perform a PUT method against our present connection.

Parameters:
  • url – The url to send the PUT request to.

  • json – JSON object to be sent.

Returns:

requests.Response object.

put_file(url: str, path: Path, data: dict, files: dict) Response

Upload a file by a PUT request.

Parameters:
  • url – The url to send the PUT request to.

  • path – Path to file to be uploaded.

  • data – Dictionary, payload to be sent for the Request, e.g. {“collectionId” : aCollection.id}

  • files – Dictionary, request library “files” object to be sent for the Request, e.g. {‘file’: (aFileName, aFileLikeObj, aContentType)}

Returns:

requests.Response object.