# Instapy-cli | Publish Photos And Videos (NEW!) On Instagram

**URL:** <https://onehack.st/t/instapy-cli-publish-photos-and-videos-new-on-instagram/140563>\
**Category:** Tools & Scripts\
**Tags:** tools, social-media, streaming\
**Created:** [October 9, 2020, 2:03pm UTC](https://onehack.st/t/instapy-cli-publish-photos-and-videos-new-on-instagram/140563 "2020-10-09T14:03:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shayla](https://onehack.st/user_avatar/onehack.st/shayla/32/174870_2.png) [@Shayla](https://onehack.st/u/Shayla)\
**Post date:** [October 9, 2020, 2:03pm UTC](https://onehack.st/t/instapy-cli-publish-photos-and-videos-new-on-instagram/140563/1 "2020-10-09T14:03:45Z")

</div>

# **instapy-cli** ⚡

Publish _photos_ and _videos_ (NEW!) on Instagram, without a phone! You can upload **posts** and even **stories** on Instagram. You can upload a local file or use a link, it does everything for you automagically.

[![instapy-cli instagram-private-api](https://raw.githubusercontent.com/instagrambot/instapy-cli/master/docs/instagram-private-banner.png)](https://raw.githubusercontent.com/instagrambot/instapy-cli/master/docs/instagram-private-banner.png)

[![Build Status](https://camo.githubusercontent.com/4f9e12d7044dabf7f9af211d398468578256b3da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50617970616c2d444f4e4154452d626c75652e7376673f6c6f676f3d70617970616c)](https://paypal.me/b3nab) [![instapy-cli version](https://camo.githubusercontent.com/bab7530a9ee0107fe03594d3ae62454f838e5238/68747470733a2f2f696d672e736869656c64732e696f2f707970692f762f696e73746170792d636c692e737667)](https://pypi.org/project/instapy-cli) [![Build Status](https://camo.githubusercontent.com/3ffbf46f6e1fa3985938b5560da6d916574276b2/68747470733a2f2f7472617669732d63692e6f72672f696e7374616772616d626f742f696e73746170792d636c692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/b3nab/instapy-cli) [![MIT license](https://camo.githubusercontent.com/be3fad5ab8e28ff8b6f56b9d443667c392e16ef0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f696e7374616772616d626f742f696e73746170792d636c692e737667)](https://github.com/b3nab/instapy-cli/blob/master/LICENSE)

[![GitHub issues](https://camo.githubusercontent.com/b643097c152c24b9d870060e51f7aaca11528f1e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f696e7374616772616d626f742f696e73746170792d636c692e737667)](https://github.com/b3nab/instapy-cli/issues) [![GitHub forks](https://camo.githubusercontent.com/8231f2e2d62cda44fb9af22494b881c714927019/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f696e7374616772616d626f742f696e73746170792d636c692e737667)](https://github.com/b3nab/instapy-cli/network) [![GitHub stars](https://camo.githubusercontent.com/7eab42e9b1816483314e02a19f62b4386c685088/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f696e7374616772616d626f742f696e73746170792d636c692e737667)](https://github.com/b3nab/instapy-cli/stargazers)

## Introduction

There are plenty of libraries written in Python specialized on working on Instagram APIs (either public or private), but most of them have lots of unsolved issues and PRs not maintained for a long time.

> Lots of developers want a simple and effective way to upload photos or videos (NEW!) directly to Instagram **programmatically**. Some may want to publish a simple post, others want to publish a story.

All this can be achieved with `instapy-cli`. 🎉

I dedided to start this repo and open-source it with ❤

### Installation

pip install instapy-cli

### Usage

#### Use as Library

You can check the folder `examples` to see working codes to use instapy-cli programmatically. If you want to use instapy-cli via shell continue reading.

#### Use as CLI

**Use**

instapy -u USR -p PSW -f FILE/LINK -t ‘TEXT CAPTION’

**CLI Options**

| option | required | default | description |
| --- | --- | --- | --- |
| -u | **yes** | - | username |
| -p | **yes** | - | password |
| -f | **yes** | - | file/media to upload |
| -t | _optional_ | - | text caption for post |
| -s | _optional_ | - | upload a story |

**Help**

instapy --help

#### Hints

##### Cookie

You can avoid to re-login, by using a cookie that instapy-cli generate for you. By default instapy-cli use the cookie created in current working directory with the name ‘USERNAME\_ig.json’. If you don’t want to store the cookie in your filesystem you need to pass the parameter `cookie`:

with client(username, password, cookie) as cli: # do stuffs with cli

This is feature is not well tested, be carefull using it.

##### Image Format

instapy-cli support images in the format of JPG/JPEG/PNG.

##### Aspect Ratio

The images need to have an aspect ratio of 1:1, that is squared size. You can use other aspect-ratio other than 1:1, but be carefull to stay inside Instagram limits. Otherwise, if you don’t respect the aspect ratio, the media will be posted but stretched or cropped.

### Why instapy-cli?

First, long story short: instapy-cli is a fork of pynstagram, with the aim of extending its functionality and fixing all unresolved bugs.

##### Move this project to a better place ↪

Anyone that wants to collaborate, I promise to be a good repo manager and merge all your pull requests as soon as possible. I have some ideas to improve this but I need collaboration. Join and support! 💡

##### But, wait! Instagram doesn’t allow uploading content except from the app (of course :trollface:)

Short answer:

> Yes, you are right.

Long answer:

> Every connection from a mobile phone could be intercepted. Someone has done the hard work to sniff the packets sent from the phone to Instagram and “spread the news”. You can do a quick research.

## Code Requirements

#### This packages will be installed automatically with _instapy-cli_

| package | Source Link |
| --- | --- |
| requests | [https://github.com/requests/requests](https://github.com/requests/requests) |
| filetype | [https://github.com/h2non/filetype.py](https://github.com/h2non/filetype.py) |
| instagram-private-api | [https://github.com/ping/instagram\_private\_api](https://github.com/ping/instagram_private_api) |
| instagram-private-api-extensions | [https://github.com/ping/instagram\_private\_api\_extensions](https://github.com/ping/instagram_private_api_extensions) |

## Contribute

To help `instapy-cli` developers to build and maintain this project, go to **[docs/CONTRIBUTING.md](https://github.com/instagrambot/instapy-cli/blob/master/docs/CONTRIBUTING.md)**

> instructions soon

(Write it and collaborate! 😉)

## License

MIT

## Support the project and the author

Offer me a coffe or a beer and support instapy-cli. 🎉

Click the button here \> [![Build Status](https://camo.githubusercontent.com/4f9e12d7044dabf7f9af211d398468578256b3da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50617970616c2d444f4e4154452d626c75652e7376673f6c6f676f3d70617970616c)](https://paypal.me/b3nab)

## GitHub:

[https://github.com/instagrambot/instapy-cli](https://github.com/instagrambot/instapy-cli)
