Building on the Upwork GraphQL API: Engineering Lessons

Diagram: a user's search profile goes through OAuth and a rate limiter to the Upwork GraphQL API; the job is normalised, scored and alerted, and after 24 hours only a hash, a score and a status remain
How one fetch cycle works in Job Hunter. The job shown is an invented example.

Every feature in Job Hunter starts with one step: getting jobs from Upwork for the search profiles each user sets up. Scoring, cover letters and alerts all depend on it. If the fetch is slow, broken or noisy, nothing after it matters. This post is about that first step: what we learned while we built a production Upwork GraphQL API integration in Laravel, and which decisions we would make again.

We keep this strictly to engineering. You will not find API keys, internal endpoints or any marketplace data here. The examples use one invented job, "Laravel developer for a booking platform", fixed price, client in Germany. It is fictional and only shows the shape of the data.

OAuth: the token is a user, not a config value

The Upwork GraphQL API uses OAuth 2.0. Each Job Hunter user connects their own Upwork account, and the fetch for that user's search profiles runs with that user's token. That sounds simple, but it changes how you think about credentials. An access token is not a setting you put in .env. It belongs to one person, it expires, and it can stop working at any moment because the user revoked access or changed a password.

So we model tokens as data with a lifecycle. Each user stores an encrypted access token, an encrypted refresh token and an expiry time. Three rules came out of the first weeks:

  • Refresh early. A token counts as expired five minutes before its real expiry time, so it is refreshed before a call fails, not after the first 401. A scheduled command also walks every connected user and refreshes tokens that are close to expiry. If two workers can refresh the same token at the same moment, a common approach is to put the refresh under a lock so that the second worker only reads the new token.
  • A missing connection is a user event, not an error. A user who has not connected Upwork is skipped by the fetch quietly, not logged as a failure on every run. A paying user who still has no connection a day after sign-up gets one email that asks them to connect, once. For a token problem, the settings page says: reconnect Upwork.
  • Never log a token. When a refresh fails, we log only the HTTP status, never the response body. Error reports go through a scrubber that replaces Bearer tokens, refresh tokens and other secret-shaped values before they leave the server. It lives in code, not in a checklist.

Rate limits: enforce them in one place, not in every caller

Any API that serves a whole marketplace has to protect itself, and the Upwork API has rate limits. Our fetch is a scheduled command that runs at a fixed interval, walks the active search profiles and calls the API for each one. The rule we learned: the limits must be enforced in one place that every call goes through, not in each caller.

So the GraphQL client has a rate limiter built on Redis counters per user: per second, per minute and per day. Before each call it checks the counters. If the second or the minute is full, it waits; if the daily cap is reached, it refuses the call instead of using up the whole day's budget. Every real HTTP attempt is counted, retries included. The heavy work after the fetch, such as AI scoring, runs in Laravel Horizon queues, with a fixed backoff between attempts.

Two details made a real difference. First, on a 429 response we respect the Retry-After header the API sends back; otherwise the client retries with a growing delay. Second, we separate retryable errors (connection failures, limits, server errors, temporary GraphQL errors) from permanent ones (missing scopes, a query that no longer fits the schema). Retrying a permanent error only burns the budget that other users need.

Schema drift: GraphQL is typed, your assumptions are not

GraphQL gives you a schema, and it is tempting to treat that as a contract that never changes. In practice, a field can become nullable, an enum can get a new value, or a field can be deprecated in favour of another one. None of this breaks the API for the provider. All of it can break your parser quietly.

Our defence has three layers:

  • Ask for exactly what you use. Our queries request only the fields the product needs. Fewer fields means fewer things that can change under you, and less data to delete later.
  • Normalise at the edge. A transformer turns each GraphQL node into our own job attributes, with a default for every field that can be missing: no title becomes "Untitled", a missing amount becomes no budget, and the contract type is detected from the fields that are present. The hard filters and the scoring model from part 2 work on these attributes, not on the API shape.
  • Give schema errors their own type. When the API answers that our query no longer fits the live schema (a field was removed or retyped), the client throws a dedicated schema exception. The job fails once instead of retrying, and the alert names the broken field. A partial response with usable data is accepted and logged as a warning. Tests use recorded fixtures instead of the live API.

The lesson: a typed API moves the risk from "the request fails" to "the request succeeds with data you misread". Validation at the boundary is cheaper than debugging a wrong score a week later.

The 24-hour data rule: deletion as a feature

The most important design decision was not about fetching at all. It was about what we keep. Job Hunter needs a job's text for a short time: to filter it, to score it, to write the cover letter draft described in part 3 and to send the alert. After that, the full text has no value for the user, and keeping it would only create risk.

So we built the 24-hour rule into the data model. After 24 hours, only three things remain per job: a hash of the job's ID, the score and the user's decision (for example "hidden"). The title, the description and all other fields are deleted. The hash lets us recognise a job we have already processed, so the same job does not come back as new, without storing what the job was.

In code, this is a scheduled pruning command that runs every hour and deletes in chunks, so it never locks large tables. The job text lives in its own table, separate from the hash, score and status, so pruning is a plain delete and not a careful update of many columns. The 24-hour limit is a hard ceiling: even if an admin sets a larger window, it is clamped to 24. Queued AI jobs receive the job model, which Laravel serialises as its ID, not as the job text. We test the rule like any other feature: tests create old and fresh rows, run the pruning and check that only the old ones are gone and that the window never exceeds 24 hours.

This rule is also what makes the EU hosting story in part 5 simple to explain: data that does not exist cannot leak.

What the API does not do

One limit shaped the product more than any other: the Upwork API does not allow submitting proposals. Job Hunter never submits anything. It finds, filters, scores and drafts, and the freelancer sends the proposal on Upwork by hand. We see that as correct, not as a workaround. The person who signs the proposal should be the one who sends it.

What we would tell another team

  • Treat OAuth tokens as user data with a lifecycle, and refresh before they expire.
  • Put every external call behind one rate limiter from the first day, and count retries too.
  • Normalise the response at the boundary and give schema errors their own type.
  • Decide what you delete before you decide what you store.

If you want to see how this pipeline feels from the user's side, the guide on how an Upwork job alert tool fits into your day walks through setup and alerts. You can also visit Job Hunter by ShvedkoDev and request access on the home page; access is by invitation. Upwork is a trademark of its owner; Job Hunter is an independent tool for Upwork freelancers.