Skip to content

Implement sync HTTP client wrapper using httpx #7

Description

@codebestia

Description

All sync resource methods need a shared internal HTTP client. This should wrap httpx.Client, set default headers (Content-Type, Accept, User-Agent), and expose a clean internal interface (get, post, patch, delete) used only by resource classes — never exposed in the public API.

Proposed Steps

  • Create src/shade/http_client.py with class _SyncHTTPClient.
  • Accept api_key, api_base, timeout in the constructor.
  • Implement request(method, path, params, json) that builds the full URL and returns a parsed response dict.
  • Set User-Agent: shade-python/{version} on every request.
  • Use httpx.Client as a context manager internally; keep a single instance alive per ShadeClient.

Acceptance Criteria

  • GET/POST/PATCH/DELETE requests are issued to the correct fully-qualified URLs.
  • User-Agent header is present on every request.
  • Content-Type: application/json is set on POST/PATCH bodies.
  • The client does not expose httpx types in its public interface.
  • Closing a ShadeClient closes the underlying httpx.Client.

Activity

  1. okeolaolatun23-glitch commented on Jun 20, 2026

    @okeolaolatun23-glitch

    Experienced in backend development, APIs, and OOP, with a strong interest in building scalable and maintainable software systems.

  2. Perruchok commented on Jun 22, 2026

    @Perruchok

    I'd like to work on this issue.

    I have experience designing Python SDKs and internal client abstractions, and I understand the importance of keeping transport details isolated from the public API. Encapsulating HTTP concerns behind a dedicated internal client improves maintainability, consistency, and makes future enhancements (retries, telemetry, auth changes) much easier.

    My approach would be to introduce a private _SyncHTTPClient in src/shade/http_client.py that serves as the shared transport layer for all synchronous resource methods.

    Specifically, I would:

    • Implement _SyncHTTPClient with api_key, api_base, and timeout parameters.

    • Maintain a single underlying httpx.Client instance for the lifetime of a ShadeClient, ensuring connection reuse and efficient resource management.

    • Add a common request(method, path, params=None, json=None) method that constructs fully-qualified URLs and returns parsed response dictionaries rather than exposing any httpx response objects.

    • Ensure all requests include consistent default headers, including:

      • User-Agent: shade-python/{version}
      • Accept: application/json
      • Content-Type: application/json for requests with JSON bodies
    • Expose simple internal helpers (get, post, patch, delete) for use by resource classes while keeping the transport layer entirely private and absent from the public SDK surface.

    • Ensure ShadeClient.close() properly closes the underlying httpx.Client, preventing connection leaks and allowing the client to participate cleanly in context-manager workflows.

    • Add tests verifying:

      • GET, POST, PATCH, and DELETE requests are sent to the correct fully-qualified URLs,
      • required headers are attached to every request,
      • JSON requests set the appropriate content type,
      • no httpx types leak through the public interface,
      • and closing a ShadeClient correctly closes the shared HTTP client.

    The goal is to provide a clean and reusable internal transport layer while preserving a stable, user-friendly SDK interface.

    Could you please assign this issue to me? Thank you.

  3. grantfox-oss commented on Jun 25, 2026

    @grantfox-oss

    🦊 GrantFox — @Perruchok has been assigned to this issue as part of the Official Campaign campaign!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #7)
    2. Your PR will be reviewed by the ShadeProtocol maintainers

    Good luck! Track your progress on GrantFox.

  4. sherifatolanike commented on Jul 22, 2026

    @sherifatolanike

    I would like to work on this issue I have reviewed the requirements for creating the internal sync HTTP client and I am ready to build the solution
    Proposed Approach
    1 HTTP Client Wrapper Create SyncHTTPClient wrapping httpx Client with api key api base and timeout settings while setting default headers like User Agent and Content Type application json
    2 Method Abstraction Implement request method handling GET POST PATCH and DELETE calls to parse response dicts while keeping httpx types hidden from the public API
    3 Lifecycle Management Keep a single httpx Client instance active per ShadeClient and ensure underlying connections close properly on client shutdown
    Please assign this issue to me so I can begin drafting the implementation

  5. grantfox-oss commented on Jul 24, 2026

    @grantfox-oss

    🦊 GrantFox — @Perruchok has been assigned to this issue as part of the Official Campaign | FWC26 campaign!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #7)
    2. Your PR will be reviewed by the ShadeProtocol maintainers

    Good luck! Track your progress on GrantFox.

  6. codebestia commented on Jul 27, 2026

    @codebestia
    ContributorAuthor

    Hello @Perruchok
    What is the update with this task.
    Please raise a PR soon

  7. DioChuks commented on Aug 18, 2026

    @DioChuks
    Contributor

    Hi, i worked on sth similar in a php project, i'm a senior swe and i see that the task ahead requires syncing resource methods via a shared internal HTTP client. I'll go about it by: creating src/shade/http_client.py with class _SyncHTTPClient, ensure to
    accept api_key, api_base, timeout in the constructor. And i'll implement request(method, path, params, json) that builds the full URL and returns a parsed response dict.
    It's very important to have one's own user-agent, so i'll also make sure this is Set User-Agent: shade-python/{version} part of it on every request. I'd love to work on it.

  8. added
    GrantFox OSSIssue tracked in GrantFox OSS
    Maybe RewardedIssue may be eligible for a GrantFox reward
    and removed
    Maybe RewardedIssue may be eligible for a GrantFox reward
    GrantFox OSSIssue tracked in GrantFox OSS
    on Aug 21, 2026
  9. grantfox-oss commented on Aug 21, 2026

    @grantfox-oss

    🦊 GrantFox — @DioChuks has been assigned to this issue as part of the Third Campaign campaign!

    Next steps:

    1. Open a Pull Request referencing this issue (e.g., Closes #7)
    2. Your PR will be reviewed by the ShadeProtocol maintainers

    Good luck! Track your progress on GrantFox.

  10. DioChuks commented on Aug 27, 2026

    @DioChuks
    Contributor

    Thank you, will get started immediately

  11. grantfox-oss commented on Aug 28, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox as part of the Third Campaign campaign!

    @DioChuks's PR #57 was approved and merged by @codebestia.

    🏆 @DioChuks: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (357 total points). Track your full progress on GrantFox.

    👏 Great work, @DioChuks! Keep contributing to ShadeProtocol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions