Sign in with PSX Lens
Let people sign in with their PSX Lens account and bring their watchlist and portfolios into your app. Every token also reads PSX market and company data. Free while in beta.
How it works
- Your app sends the person to PSX Lens to sign in and approve what you ask for.
- They come back to your app with a code, which you exchange for an access token.
- With that token you read and write their data for as long as they stay connected. They can disconnect your app at any time from the API page.
The person's data stays in one place, so the watchlist they build in your app is the same one they see on PSX Lens and in every other app they connect.
Scopes
| profile:read | Account id, email and join date |
| watchlist:read | The watchlist with today's prices, and the daily digest of news on it |
| watchlist:write | Add and remove watchlist stocks (includes watchlist:read) |
| portfolio:read | Portfolios, holdings, trades, profit and loss, dividends |
| portfolio:write | Record, edit and delete trades and portfolios (includes portfolio:read) |
Ask only for what you need. The person sees each item on the approval screen and may grant read access instead of write.
1. Register your app
The easiest way is the developer dashboard: sign in, add your app and its return addresses, and copy the client id. You also see how many people have connected. Or register from code (https, or http on localhost while you build):
curl -X POST https://api.psxlens.com/v1/oauth/register \
-H 'content-type: application/json' \
-d '{"client_name":"My PSX App","redirect_uris":["https://myapp.example/callback"]}'
# -> { "client_id": "pcl_...", ... }2. Send the person to sign in
Create a random code verifier, keep it, and send its SHA-256 (base64url) as the challenge. This is OAuth 2.1 with PKCE; no client secret is needed.
https://psxlens.com/oauth/authorize ?response_type=code &client_id=pcl_... &redirect_uri=https://myapp.example/callback &scope=profile:read watchlist:write &state=RANDOM_STATE &code_challenge=BASE64URL_SHA256_OF_VERIFIER &code_challenge_method=S256
3. Exchange the code
curl -X POST https://api.psxlens.com/v1/oauth/token \
-d grant_type=authorization_code \
-d code=CODE_FROM_REDIRECT \
-d code_verifier=YOUR_VERIFIER \
-d client_id=pcl_... \
-d redirect_uri=https://myapp.example/callback
# -> { "access_token": "pl_live_...", "token_type": "Bearer", "scope": "profile:read watchlist:write" }Store the token on your server. It does not expire; it stops working when the person disconnects your app.
4. Call the API
curl https://api.psxlens.com/v1/me/profile -H 'authorization: Bearer pl_live_...'
curl https://api.psxlens.com/v1/me/watchlist -H 'authorization: Bearer pl_live_...'
curl -X POST https://api.psxlens.com/v1/me/watchlist -H 'authorization: Bearer pl_live_...' \
-H 'content-type: application/json' -d '{"symbol":"OGDC"}'
curl -X DELETE https://api.psxlens.com/v1/me/watchlist/OGDC -H 'authorization: Bearer pl_live_...'
curl https://api.psxlens.com/v1/me/digest -H 'authorization: Bearer pl_live_...'
curl https://api.psxlens.com/v1/me/portfolios -H 'authorization: Bearer pl_live_...'Every endpoint, with its fields, is in the API reference. Market endpoints such as quotes, the screener, beta and dividends work with the same token.
Limits and pricing
- Free during the beta, for any number of users.
- 600 requests a minute per token; 120 a minute without one.
- Prices are delayed and published once a day after the close. PSX Lens does not place orders or move money, and no token can.