Skip to content

MUSAFFA B2B API (1.0.0)

Musaffa’s API is one of the most comprehensive Shariah-Compliant Stock Screener organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.

All requests are made to endpoints beginning: https://b2b.musaffa.us/b2b/api.

Developer Agreement

By using Musaffa’s API, you agree to our Terms of Use.

Rate Limits

There are limitations for the API calls.

Depending on the B2B subscription plan it can be up to 100 000 API calls per month and 1 API call per second.

If your limit is exceeded, you will receive a response with status code 429.

Authentication and API

Musaffa will provide a secret key and a client ID to every B2B client.

secretKey=< should be shared separately for each client >
clientId=< should be shared separately for each client >

UTC is used for time zone “UTC+5”

TimeZone = "UTC"
DateTimeFormatter = "yyyyMMddHHmmss"

Using current time, the secret key, the client ID and a body of the message a token is generated using the following code:

token = Base64.getEncoder().encodeToString(DigestUtils.sha512 (secretKey + time + json String body))

The token is placed in the header of the message for both sides of the communication and used for validating messages.

Example Token Generation

String secretKey = "gRUsdfsdfkv8yBEyQWGbPeShVmYq3tREWRC&F)JMcQfTjWnZ"
String jsonInStringBody = "{"stock":"AAPL"}"
String time = ZonedDateTime.ofInstant(nowUtc,zoneId).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
String token = Base64.getEncoder().encodeToString(DigestUtils.sha512(secretKey + time + jsonInStringBody));
Download OpenAPI description
Overview
Languages
Servers
Mock server

https://docs.musaffa.us/_mock/apis/

https://b2b.musaffa.us/b2b/api/

https://b2b.musaffa.us/b2b/api/v1/

Operations
Operations

Customer Account

Customer account management APIs

Operations

Request

Get the Request Statistics of your account.

Response body:

ParameterTypeDescription
clientIdstringClient ID
companyNamestringCompany Name
subscriptionPlanstringSubscription Plan
monthlyRequestLimitnumberMonthly request limit
activeMonthRequestAmountnumberNumber of requests made for the active month
lastRequestDatedateTimeLast request date
subscriptionEndDatedateTimeSubscription end date
activeMonthStartDatedateTimeStart date of the active month
Security
MusaffaAuth
Headers
clientidstring
Example: AX6kFk5ywERyZacb
timestring
Example: {{time}}
tokenstring
Example: {{token}}
curl -i -X GET \
  https://docs.musaffa.us/_mock/apis/v1/b2b-users/statistics \
  -H 'clientid: AX6kFk5ywERyZacb' \
  -H 'time: {{time}}' \
  -H 'token: YOUR_API_KEY_HERE'

Responses

CUSTOMER CALL STATISTICS v.1 / CUSTOMER CALL STATISTICS v.1

Headers
Connectionstring
Example: "keep-alive"
Datestring
Example: "Fri, 16 Jun 2023 06:48:28 GMT"
Serverstring
Example: "nginx/1.18.0 (Ubuntu)"
Transfer-Encodingstring
Example: "chunked"
Varystring
Example: "Access-Control-Request-Headers"
Bodyapplication/json
activeMonthRequestAmountnumber
Example: 146
activeMonthStartDatestring
Example: "2023-06-14T12:00:00.7105"
clientIdstring
Example: "test-4WkMxTnpRcEdhRW1Sbk"
companyNamestring
Example: "TEST"
lastRequestDatestring
Example: "2023-06-16T06:48:16.547655"
monthlyRequestLimitnumber
Example: 100000
subscriptionEndDatestring
Example: "2023-07-14T12:00:00.7105"
subscriptionPlanstring
Example: "Annual Premium"
Response
application/json
{ "activeMonthRequestAmount": 146, "activeMonthStartDate": "2023-06-14T12:00:00.7105", "clientId": "test-4WkMxTnpRcEdhRW1Sbk", "companyName": "TEST", "lastRequestDate": "2023-06-16T06:48:16.547655", "monthlyRequestLimit": 100000, "subscriptionEndDate": "2023-07-14T12:00:00.7105", "subscriptionPlan": "Annual Premium" }