I need to get response from sending request to the AWS. I have the secretkey/AccessKey of AWS.
What is the method/syntax to access the aws APi, for example GetCredentialReport is an API of AWS, How to access this api?
You can use get_credential_report() API in boto3 for credential repot
get_credential_report()
Retrieves a credential report for the AWS account. For more information about the credential report, see Getting Credential Reports in the IAM User Guide .
See also: AWS API Documentation
Request Syntax
response = client.get_credential_report()
Response Structure
(dict) --
Contains the response to a successful GetCredentialReport request.
Content (bytes) --
Contains the credential report. The report is Base64-encoded.
ReportFormat (string) --
The format (MIME type) of the credential report.
GeneratedTime (datetime) --
The date and time when the credential report was created, in ISO 8601 date-time format.
Try this code
import os
import boto3
from dotenv import load_dotenv
load_dotenv()
AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.getenv('AWS_SECRET_ACCESS_KEY')
client = boto3.client(
    'iam',
    aws_access_key_id=AWS_ACCESS_KEY_ID,
    aws_secret_access_key=AWS_SECRET_ACCESS_KEY
)
response = client.generate_credential_report()
How to get response and access the AWS Api with python?