Skip to content

Resolve issues with memory consumption in the python SDK #123

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

Merged
merged 1 commit into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 61 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ pip install MergePythonClient

A full reference for this library is available [here](https://github.com/merge-api/merge-python-client/blob/HEAD/./reference.md).

## Usage

Instantiate and use the client with the following:

```python
from merge import Merge
from merge.resources.ats import ActivityRequest

client = Merge(
account_token="YOUR_ACCOUNT_TOKEN",
api_key="YOUR_API_KEY",
)
client.ats.activities.create(
model=ActivityRequest(),
remote_user_id="remote_user_id",
)
```

## Instantiation

```python
Expand All @@ -42,24 +60,6 @@ client.ats. # APIs specific to the ATS Category
client.hris. # APIs specific to the HRIS Category
```

## Usage

Instantiate and use the client with the following:

```python
from merge import Merge
from merge.resources.ats import ActivityRequest

client = Merge(
account_token="YOUR_ACCOUNT_TOKEN",
api_key="YOUR_API_KEY",
)
client.ats.activities.create(
model=ActivityRequest(),
remote_user_id="remote_user_id",
)
```

## Async Client

The SDK also exports an `async` client so that you can make non-blocking calls to our API.
Expand Down Expand Up @@ -101,49 +101,6 @@ except ApiError as e:
print(e.body)
```

## File Download

```python
import merge
from merge.client import Merge

merge_client = Merge(
api_key="<YOUR_API_KEY>",
account_token="<YOUR_ACCOUNT_TOKEN>")

files = merge_client.filestorage.files.list(name="<FILE_NAME>").results

id = files[0].id
name = files[0].name
local_filename = f"<LOCAL_FILE_PATH>/{name}"

response = merge_client.filestorage.files.download_retrieve(id=id)
with open(local_filename, "wb") as f:
for chunk in response:
f.write(chunk)
```

## Pagination

The SDK may return paginated results. Endpoints that return paginated results will
include a `next` and `prev` property on the response. To get the next page, you can
pass in the value of `next` to the cursor property on the request. Similarly, to
get the previous page, you can pass in the value of `prev` to the cursor property on
the request.

Below is an example of iterating over all pages:
```python

# response contains the first page
response = merge_client.hris.employees.list(created_after="2030-01-01")

# if there is a next page, load it by passing `next` to the cursor argument
while response.next is not None:
response = hris_client.employees.list(
cursor=response.next,
created_after="2030-01-01")
```

## Advanced

### Access Raw Response Data
Expand Down Expand Up @@ -229,3 +186,46 @@ a proof of concept, but know that we will not be able to merge it as-is. We sugg
an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!
## File Download

```python
import merge
from merge.client import Merge

merge_client = Merge(
api_key="<YOUR_API_KEY>",
account_token="<YOUR_ACCOUNT_TOKEN>")

files = merge_client.filestorage.files.list(name="<FILE_NAME>").results

id = files[0].id
name = files[0].name
local_filename = f"<LOCAL_FILE_PATH>/{name}"

response = merge_client.filestorage.files.download_retrieve(id=id)
with open(local_filename, "wb") as f:
for chunk in response:
f.write(chunk)
```

## Pagination

The SDK may return paginated results. Endpoints that return paginated results will
include a `next` and `prev` property on the response. To get the next page, you can
pass in the value of `next` to the cursor property on the request. Similarly, to
get the previous page, you can pass in the value of `prev` to the cursor property on
the request.

Below is an example of iterating over all pages:
```python

# response contains the first page
response = merge_client.hris.employees.list(created_after="2030-01-01")

# if there is a next page, load it by passing `next` to the cursor argument
while response.next is not None:
response = hris_client.employees.list(
cursor=response.next,
created_after="2030-01-01")
```

10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "MergePythonClient"

[tool.poetry]
name = "MergePythonClient"
version = "2.0.0"
version = "2.1.0"
description = ""
readme = "README.md"
authors = []
Expand Down Expand Up @@ -37,7 +37,7 @@ Repository = 'https://github.com/merge-api/merge-python-client'
python = "^3.8"
httpx = ">=0.21.2"
pydantic = ">= 1.9.2"
pydantic-core = "^2.18.2"
pydantic-core = ">=2.18.2"
typing_extensions = ">= 4.0.0"

[tool.poetry.group.dev.dependencies]
Expand Down
Loading