# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [1.0.0] - 2026-12-03

### Breaking

The client is rebuilt on code generated from Apify's OpenAPI description. The
old resource API is gone; see the README for the new one.

- Removed `ApifyClient.new`, the `%ApifyClient{}` struct, `ApifyClient.Resources.*`,
  `ApifyClient.Base.*`, `ApifyClient.HTTPClient` and `ApifyClient.Pagination`.
  Calls take their settings as options (`config: %ApifyClient.Config{}`, `token:`, ...).
  Connection settings are not read from the application environment, and the token
  is no longer read from the `APIFY_TOKEN` environment variable: pass it explicitly
  (`token: System.fetch_env!("APIFY_TOKEN")`). Without a token, requests are sent
  unauthenticated.
- Responses are structs from `ApifyClient.Schemas` with snake_case fields
  (`run.default_dataset_id` instead of `run["defaultDatasetId"]`), timestamps as
  `DateTime`, and the `{"data": ...}` envelope removed.
- Query options are snake_case and sent under the API's camelCase names
  (`max_items: 10` becomes `maxItems=10`; the old client sent them in snake_case).
- Calls without a response body (deletes, `HEAD`) return `:ok`.
- `ApifyClient.Error` is now an exception; `details` has `:status_code`,
  `:error_type` (the API's error type) and `:body`.
- Telemetry `:resource` for Actor endpoints is `"actors"` (the client now uses
  `/v2/actors/...` instead of the deprecated `/v2/acts/...`).
- Require Elixir 1.18+ (CI covers 1.18/OTP 27 through 1.20/OTP 29).
- Require Req `~> 0.7`.
- Jason is no longer a direct dependency (Req still pulls it in transitively). JSON goes
  through the new `ApifyClient.JSON` behaviour and defaults to Elixir's built-in `JSON`
  (`ApifyClient.JSON.Native`).
  Structs that only implement `Jason.Encoder` need `JSON.Encoder`, or set
  `config :apify_client, :json_library, ApifyClient.JSON.Jason`.
- Actor IDs in `username/actor-name` form are sent as `username~actor-name`, as the
  API documents (`ApifyClient.Actors.safe_id/1`).

### Added
- `ApifyClient.API.*`: every operation of the Apify API (226), generated from its
  OpenAPI description, with the schemas as structs in `ApifyClient.Schemas`.
- `ApifyClient.Actors`, `ApifyClient.Tasks`, `ApifyClient.Runs`,
  `ApifyClient.Builds`, `ApifyClient.Datasets`, `ApifyClient.KeyValueStores` and
  `ApifyClient.Logs` for common tasks: start an Actor or task and wait for it,
  build an Actor and wait for the build, stream dataset items and store keys
  page by page, read and write records, follow logs.
- `ApifyClient.Pagination.stream/2` streams every item of any paginated list
  endpoint.
- Retries for rate limits, server errors and network errors, with randomized
  exponential backoff. `max_retries` and `min_delay_between_retries_ms` were
  accepted before but never used.
- `ApifyClient.JSON` behaviour with `ApifyClient.JSON.Native` and `ApifyClient.JSON.Jason`
  adapters, configurable globally (`config :apify_client, :json_library, ...`) or per
  call (`json_library: ...`).

### Changed
- The User-Agent reports the actual library version instead of a hardcoded `0.1.0`.
- Dev shell targets Elixir 1.20 / OTP 29.
- Removed the unused `mox` test dependency.
- Removed the unused `nimble_options` dependency and the `bypass` and `reqord` test
  dependencies.

### Fixed
- Network errors are returned as `{:error, %ApifyClient.Error{}}` instead of raising.
- Error responses whose `error` is a plain string no longer crash.

## [0.2.0] - 2026-07-23

## Added
- extended telemetry with spans

## [0.1.0] - 2025-10-05

### Added
- Initial release of the Apify Client for Elixir
- Complete actor management (get, call, start, build, versions)
- Dataset operations (list items, stream items, download)
- Key-value store operations (get/set records, list keys)
- Request queue management (add/get/update/delete requests)
- Run monitoring and management (wait for finish, get status, abort)
- Build management and monitoring
- User account information and usage statistics
- Schedule management (CRON-based automation)
- Webhook management (event handling and testing)
- Apify Store browsing and search
- Comprehensive pagination utilities with streaming support
- Automatic retry logic with exponential backoff
- Structured error handling with 12+ specific error types
- Configuration management with environment variable support
- HTTP client based on Req library
- Memory-efficient streaming for large datasets
- Complete API coverage matching JavaScript client
- Elixir-specific enhancements:
  - `{:ok, result} | {:error, error}` tuple patterns
  - Stream processing for large data
  - Automatic pagination streaming
  - Rich typespec definitions
  - Comprehensive documentation with examples

### Features
- **Actors**: Run, manage, and monitor Apify actors
- **Datasets**: Efficiently process large datasets with streaming
- **Key-Value Stores**: Store and retrieve arbitrary data
- **Request Queues**: Manage crawling queues
- **Schedules**: Automate actor runs with CRON expressions
- **Webhooks**: Handle real-time notifications
- **User Management**: Access account info and usage statistics
- **Store Integration**: Browse and search Apify Store
- **Streaming**: Memory-efficient processing of large datasets
- **Pagination**: Automatic handling of paginated responses
- **Error Handling**: Comprehensive error types and messages
- **Retry Logic**: Automatic retries with exponential backoff

### Technical Details
- Requires Elixir 1.17+
- Uses Req for HTTP requests
- JSON processing with Jason
- Configuration validation with NimbleOptions
- Comprehensive test coverage
- Complete ExDoc documentation
- Dialyzer type checking support

[Unreleased]: https://github.com/social-growth-studio/apify-client-ex/compare/v1.0.0...HEAD
[1.0.0]: https://github.com/social-growth-studio/apify-client-ex/compare/v0.2.0...v1.0.0
[0.2.0]: https://github.com/social-growth-studio/apify-client-ex/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/social-growth-studio/apify-client-ex/releases/tag/v0.1.0
