# Targeting API Changes. ## All Accounts ##### GET {{ host }}/api/v2/accounts Change description: >Removed "total" object from targeting section. Changed "states" object name to the "buckets". Data from the "total" object can be pulled from other requests. Example analytics. In Compatibility API Response we will fake data from the "total" object because we need to make compatible data. **Old API Response:** ```sh { "status": "ok", "accounts": [ { "connected": false, "account": {...}, "shift": {...}, "dynamics": {...}, "cooldown": {...}, "warmup": {...}, "targeting": { "sources_count": 0, "states": { "to_follow": 150, "to_unfollow": 0, "to_mute": 0, "requested": 0 }, "total": { "followbacks": 977, "follows": 611, "unfollows": 102 } } } ] } ``` **New API Response:** ```sh { "status": "ok", "accounts": [ { "connected": false, "account": {...}, "shift": {...}, "dynamics": {...}, "cooldown": {...}, "warmup": {...}, "targeting": { "sources_count": 0, "buckets": { "to_follow": 150, "to_unfollow": 0, "to_mute": 0, "requested": 0 } } } ] } ``` **Compatibility API Response:** ```sh { "status": "ok", "accounts": [ { "connected": false, "account": {...}, "shift": {...}, "dynamics": {...}, "cooldown": {...}, "warmup": {...}, "targeting": { "sources_count": 0, "states": { "to_follow": 150, "to_unfollow": 0, "to_mute": 0, "requested": 0 }, "buckets": { "to_follow": 150, "to_unfollow": 0, "to_mute": 0, "requested": 0 }, "total": { "followbacks": 977, "follows": 611, "unfollows": 102 } } } ] } ``` ## Create New Source ##### POST {{host}}/api/v2/accounts/{{pk}}/sources Change description: >Removed "value" from the body which is replaced by "id" and "name". When we create source of hashtag and location. "id" and "name" are provided by instagram. When creating source of type profile "id" is "pk" from instagram profile and "name" is "username" from that instagram profile. **Old API Request:** ```sh { "type" : "location", // ["profile", "location", "hashtag"] "value" : "324128586" } ``` **New API Request:** ```sh { "type" : "profile", // ["profile", "location", "hashtag"] "id" : "23454323", "name" : "miljan" } ``` **Compatibility API Request:** For the backward compatibility when value is provided, we will use instagram request to pull out "id" and "name". That is the reason why creating source is really slow on the new targeting. When you start using new api, response will be really fast under 200ms. ```sh { "type" : "profile", // ["profile", "location", "hashtag"], "value" : "345678", "id" : "345678", "name" : "miljan" } ``` **Old API Response:** ```sh { "status": "ok", "source": { "id": 687391, "followbacks": 0, "follows": 0, "unfollows": 0, "status": "pending", "type": "hashtag", "value": "graphicdesigners" } } ``` **New Api Response:** You can use id from request body to save it in your database, so if you would like to remove source. You can do it with that id. ```sh { "status": "ok" } ``` **Compatibility API Response:** After creation we will return newly created source so it is backward compatibility. ```sh { "status": "ok", "source": { "type": "profile", "name": "kevin", "id": "3", "value": "3", "status": "init", "follows": 985, "followbacks": 756, "unfollows": 190, "extra" : { "volume": 7833904, "is_private": false, "is_verified": true, "profile_pic_url": "https:\/\/scontent-mia3-2.cdninstagram.com" } } } ``` ## Delete Source ##### DELETE {{host}}/api/v2/accounts/{{pk}}/sources/{{source_id}} Change description: >URL is changed when removing source on the new api. In the old api you need to provide only {{source_id}}. On the new api, we need {{type}} and {{source_id}} when removing source. Type is profile, location or hashtag. **Old API Request** ```sh DELETE {{host}}/api/v2/accounts/{{pk}}/sources/{{source_id}} ``` **New API Request** ```sh DELETE {{host}}/api/{{api}}/accounts/{{pk}}/sources/{{source_type}}/{{source_id}} ``` **Compatibility API Request** We provide both requests. So you can test deletion of the source on the new version. ```sh DELETE {{host}}/api/v2/accounts/{{pk}}/sources/{{source_id}} DELETE {{host}}/api/{{api}}/accounts/{{pk}}/sources/{{source_type}}/{{source_id}} ``` ## List Sources ##### GET {{host}}/api/v2/accounts/{{pk}}/sources Change description: >Removed metrics per source. So ["followbacks", "follows", "unfollows"] are removed, "value" is removed because it is replaced with "id" and "name". When source type is profile, "user" object is removed. **Old API Response:** ```sh { "status": "ok", "sources": [ { "id": 353523, "followbacks": 78, "follows": 1099, "unfollows": 1094, "status": "ready", "type": "hashtag", "value": "love" }, { "id": 380607, "followbacks": 0, "follows": 55, "unfollows": 55, "status": "ready", "type": "profile", "value": "532921297", "user": { "pk": 532921297, "username": "hafidderradji", "full_name": "Hafid Derradji حفيظ دراجي", "is_private": false, "is_verified": true, "is_business": true, "follower_count": 2732657, "following_count": 282, "media_count": 1285, "profile_pic_url": "https://instagram.fbeg9-1.f", "category": "Sports" } }, { "id": 415590, "followbacks": 0, "follows": 0, "unfollows": 0, "status": "ready", "type": "location", "value": "443523348" } ] } ``` **New API Response:** New data that is added for every source. ['name', 'id', 'volume', 'profile_pic_url'] When source is profile we have additional data: ['is_verified', 'is_private'] When source is location we have additional data: ['is_verified', 'is_private', 'lat', 'lng'] On the new api "id" and "name" are provided by instagram. When adding profile as a source "id" is instagram pk from that profile and name is username from that profile. We will always provide ["type", "name", "id", "status"]. Sometimes we won't have extra data, se we will set default values, for strings it will be '', booleans false, integers/double/float 0. ```sh { "status": "ok", "sources": [ { "type": "profile", "name": "tabasco", "id": "763829", "status": "ready", "extra" : { "volume": 602525, "is_private": false, "is_verified": true, "profile_pic_url": "https:\/\/scontent-mia3-2.cdninstagram.com" } }, { "type": "hashtag", "name": "japanesefoodculture", "id": "747919", "status": "init", "extra" : { "volume": 445, "profile_pic_url": "https:\/\/scontent-mia3-2.cdninstagram.com" } }, { "status": "mining", "type": "location", "name": "Soho New York", "id": "370378", "extra" : { "volume": 123, "slug": "soho-new-york", "lat": 40.73344039916992, "lng": -73.99891662597656, "profile_pic_url": "https:\/\/scontent-mia3-2.cdninstagram.com" } } ] } ``` **Compatibility API Response:** This response added "adapter_id". This adapter id shold be replaced with the current id that is provided in the source object. Because on the new version of api, we will use id which will be different that the id's from the old api. On the new API id will be the id that you gave us when we have created source. So we have provided you adapter_id so you can change your current id to that. Metrics per source ["followbacks", "follows", "unfollows"] are currently fake values. They are only here so we do not break the backward compatibility. "volume" is removed in the new version of api, instead of volume you can use "name" or "id" on the new api. ```sh { "status": "ok", "sources": [ { "type": "profile", "name": "danawhite", "id": "380603", "status": "mining", "adapter_id": "566328842", "follows": 930, "followbacks": 345, "unfollows": 151, "value": "566328842", "extra": { "volume": 5515461, "is_private": false, "is_verified": true, "profile_pic_url": "https://scontent-lga3-1.cdninst" }, "user": { "pk": 566328842, "username": "danawhite", "full_name": "Dana White", "is_private": false, "is_verified": true, "is_business": true, "follower_count": 5515461, "following_count": 1942, "media_count": 7183, "profile_pic_url": "https://scontent-lga3-1.cdninsta", "category": "SPORTS" } }, { "type": "location", "name": "Thea and Lysa online store", "id": "353540", "status": "depleted", "adapter_id": "102524641397566", "follows": 493, "followbacks": 242, "unfollows": 43, "value": "102524641397566", "extra": { "volume": 123, "slug": "thea-and-lysa-online-store", "lat": 42.63768005371094, "lng": -71.3211898803711, "profile_pic_url": "https://scontent-mia3-2.cdninstagram.co" } }, { "type": "hashtag", "name": "lovers", "id": "350263", "status": "mining", "adapter_id": "17841563824118780", "follows": 238, "followbacks": 18, "unfollows": 47, "value": "lovers", "extra": { "volume": 1591234, "profile_pic_url": "https://scontent-mia3-2.cdninstagram." } } ] } ``` ## Update Filters ##### PATCH {{host}}/api/v2/accounts/{{pk}}/filters Change description: >Request is the same. Just some ranges have changed. Please check difference between range changes. **Old API Range:** ```sh { 'following.min' => 'between:10,600', 'following.max' => 'between:1000,7500', 'followers.min' => 'between:10,500', 'followers.max' => 'between:1000,20000', 'media.min' => 'between:0,30', 'media.max' => 'between:100,1000', 'average_likes.min' => 'min:0', 'average_likes.max' => 'min:0', 'last_active' => 'min:1', 'nsfw_filter' => [true, false], 'gender' => ['male','female','any'], 'privacy' => ['public','private','any'] } ``` **New API Range:** ```sh { 'following.min' => 'between:10,500', 'following.max' => 'between:1000,7500', 'followers.min' => 'between:10,500', 'followers.max' => 'between:1000,20000', 'media.min' => 'min:5', 'media.max' => 'between:100,1000', 'average_likes.min' => 'min:5', 'average_likes.max' => 'between:100,1000', 'last_active' => 'between:1,30' 'nsfw_filter' => [true, false], 'gender' => ['male','female','any'], 'privacy' => ['public','private','any'] } ```