2 min read
requestsStandard lib choice
read+writeBoth shown
Retry-AfterHonoured
Read the loyalty tiers
import requests, time
r = requests.get('https://hub.credicorp.co.uk/public/v1/loyalty/tiers')
if r.status_code == 429:
time.sleep(int(r.headers.get('Retry-After', '1')))
r = requests.get('https://hub.credicorp.co.uk/public/v1/loyalty/tiers')
for t in r.json()['tiers']:
print(t['name'], t['benefit']['arrangement_fee_discount_pct'], '%')
Submit an enquiry
import requests
r = requests.post(
'https://hub.credicorp.co.uk/public/v1/enquiries',
json={
'form': 'contact-us', 'dept': 'support',
'fields': {'name': 'Jordan', 'email': '[email protected]', 'consent': 'yes'},
},
)
if r.status_code == 201:
print('enquiry', r.json()['id'])
else:
print('error', r.json()['error']['code'])
Notes
requests sends JSON and the right Content-Type when you use json=. Remember percent units on the discount and the mandatory consent flag. See the loyalty reference.
Frequently asked questions
Does requests set the Content-Type for me?
Yes — passing json= sends the body as JSON with Content-Type: application/json automatically.
Funding for UK limited companies
Credicorp lends to your company, not to you personally — short-term working capital with no personal guarantee. See what your business could access.