After creating a charge how to extract 'code' or 'hosted_url' from JSON Response

I made a charge that is creating after pressing the button, and JSON Response is printing with python in my Command Line, how to extract from JSON Response code in order to put in in a redirect link, and redirect the customer on this charge page

    url = ""
    payload = {
        "local_price": {
            "amount": 0.001,
            "currency": "BTC"
        "name": "Deposit cryptocurrency",
        "description": "In order to replenish, you need to deposit your cryptocurrency",
        "pricing_type": "fixed_price"
    headers = {
        "accept": "application/json",
        "X-CC-Version": "2018-03-22",
        "content-type": "application/json"

    response =, json=payload, headers=headers)
    code = { somehow to extract code from upper response }

And here I need to put code in a variable in order to redirect customer to this page

     render(request, f'{code}')

Hello @Fors1t ! We are only able to provide guidance and troubleshooting for issues with the raw Coinbase APIs. Unfortunately we are unable to provide guidance on how to write code in specific programming languages and frameworks, and cannot assist further on this request. Thank you for understanding!

1 Like