python-3.xpinterestpinterest-api

Pinterest API V5 Create Pins With Local Images


I'm trying to make a pinner app with official Pinterest API. I completed most of the features, but I'm struggling with creating pins.

I can't create a pin with my local files like:

MEDIA_SOURCE = 
{                 
"source_type": "image_url",                 
"content_type": "image/jpeg",                 
"data": "string",
'url':'C:/Users/USER/Images/Cat/3D62226C-A2F9-4171-BF04-B03AF416CD46.jpg'          
}

HTTP response body: {"code":1,"message":"Parameter 'image url' with the value 'C:/Users/USER/Images/Cat/3D62226C-A2F9-4171-BF04-B03AF416CD46.jpg' is not a valid URL format."}

Pinterest gives me this error.

I tried with this media_source template. It works like expected. So, I can use https url's in this dictionary but not local file url's. I think I should change source_type value in the dictionary but I couldn't find the parameters that can be usable for this source_type value.

MEDIA_SOURCE = 
{                 
"source_type": "image_url",                 
"content_type": "image/jpeg",                 
"data": "string",                 
'url':'https://URL-TO-IMAGE.jpg'                 
}

Solution

  • I contacted with Pinterest developer support. Currently (June, 2023) local image sharing is not available. So we have to host image in a server. Than we can share a pin with this media source dictionary:

    MEDIA_SOURCE = 
    {                 
    "source_type": "image_url",                 
    "content_type": "image/jpeg",                 
    "data": "string",                 
    'url':'https://URL-TO-IMAGE.jpg'                 
    }