Documentation ¶
Overview ¶
AUTHOR:HARSH AGRAWAL 19BCE10101
AUTHOR:HARSH AGRAWAL 19BCE10101
AUTHOR:HARSH AGRAWAL 19BCE10101
AUTHOR:HARSH AGRAWAL 19BCE10101
AUTHOR:HARSH AGRAWAL 19BCE10101
AUTHOR:HARSH AGRAWAL 19BCE10101
AUTHOR:HARSH AGRAWAL19BCE10101
AUTHOR:HARSH AGRAWAL 19BCE10101
Index ¶
- Constants
- func CheckResponse(r *http.Response) error
- func TestCommentsService_Add(t *testing.T)
- func TestCommentsService_Delete(t *testing.T)
- func TestCommentsService_MediaComments(t *testing.T)
- func TestGeographiesService_RecentMedia(t *testing.T)
- func TestLocationsService_Get(t *testing.T)
- func TestLocationsService_RecentMedia(t *testing.T)
- func TestLocationsService_Search(t *testing.T)
- func TestMediaService_Get(t *testing.T)
- func TestMediaService_Popular(t *testing.T)
- func TestMediaService_Search(t *testing.T)
- func TestNewClient(t *testing.T)
- func TestNewRequest(t *testing.T)
- func TestRelationshipsService_FollowedBy_self(t *testing.T)
- func TestRelationshipsService_FollowedBy_userId(t *testing.T)
- func TestRelationshipsService_Follows_self(t *testing.T)
- func TestRelationshipsService_Follows_userId(t *testing.T)
- func TestRelationshipsService_Relationship(t *testing.T)
- func TestRelationshipsService_RequestedBy(t *testing.T)
- func TestRelationshipsService_actions(t *testing.T)
- func TestUsersService_Get_self(t *testing.T)
- func TestUsersService_Get_userId(t *testing.T)
- func TestUsersService_LikedMedia(t *testing.T)
- func TestUsersService_MediaFeed(t *testing.T)
- func TestUsersService_RecentMedia(t *testing.T)
- func TestUsersService_Search(t *testing.T)
- type Client
- type Comment
- type CommentsService
- type ErrorResponse
- type GeographiesService
- type Location
- type LocationsService
- type Media
- type MediaCaption
- type MediaComments
- type MediaImage
- type MediaImages
- type MediaLikes
- type MediaLocation
- type MediaService
- type MediaVideo
- type MediaVideos
- type Parameters
- type Ratelimit
- type Relationship
- type RelationshipsService
- func (s *RelationshipsService) Approve(userId string) (*Relationship, error)
- func (s *RelationshipsService) Block(userId string) (*Relationship, error)
- func (s *RelationshipsService) Deny(userId string) (*Relationship, error)
- func (s *RelationshipsService) Follow(userId string) (*Relationship, error)
- func (s *RelationshipsService) FollowedBy(userId string) ([]User, *ResponsePagination, error)
- func (s *RelationshipsService) Follows(userId string) ([]User, *ResponsePagination, error)
- func (s *RelationshipsService) Relationship(userId string) (*Relationship, error)
- func (s *RelationshipsService) RequestedBy() ([]User, *ResponsePagination, error)
- func (s *RelationshipsService) Unblock(userId string) (*Relationship, error)
- func (s *RelationshipsService) Unfollow(userId string) (*Relationship, error)
- type Response
- func (r *Response) GetData() interface{}
- func (r *Response) GetError() error
- func (r *Response) GetMeta() *ResponseMeta
- func (r *Response) GetPagination() *ResponsePagination
- func (r *Response) GetRatelimit() (Ratelimit, error)
- func (r *Response) NextMaxID() string
- func (r *Response) NextURL() string
- type ResponseMeta
- type ResponsePagination
- type User
- type UserCount
- type UserInPhoto
- type UserInPhotoPosition
- type UsersService
- func (s *UsersService) Get(userId string) (*User, error)
- func (s *UsersService) LikedMedia(opt *Parameters) ([]Media, *ResponsePagination, error)
- func (s *UsersService) MediaFeed(opt *Parameters) ([]Media, *ResponsePagination, error)
- func (s *UsersService) RecentMedia(userId string, opt *Parameters) ([]Media, *ResponsePagination, error)
- func (s *UsersService) Search(q string, opt *Parameters) ([]User, *ResponsePagination, error)
Constants ¶
const ( // LibraryVersion represents this library version LibraryVersion = "0.5" // BaseURL represents Instagram API base URL BaseURL = "https://api.instagram.com/v1/" // UserAgent represents this client User-Agent UserAgent = "github.com/harsh3125/Instagram-backend-api" + LibraryVersion )
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for error, and returns it if present. A response is considered an error if it has non StatusOK code.
func TestCommentsService_Add ¶
func TestMediaService_Get ¶
func TestMediaService_Search ¶
func TestNewClient ¶
func TestNewRequest ¶
func TestUsersService_Search ¶
Types ¶
type Client ¶
type Client struct { // Base URL for API requests. BaseURL *url.URL // UserAgent agent used when communicating with Instagram API. UserAgent string // Application client_id ClientID string // Application client_secret ClientSecret string // Authenticated user's access_token AccessToken string // Services used for talking to different parts of the API. Users *UsersService Relationships *RelationshipsService Media *MediaService Comments *CommentsService Likes *LikesService Tags *TagsService Locations *LocationsService Geographies *GeographiesService // Temporary Response Response *Response // contains filtered or unexported fields }
A Client manages communication with the Instagram API.
func NewClient ¶
NewClient returns a new Instagram API client. if a nil httpClient is provided, http.DefaultClient will be used.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified
type CommentsService ¶
type CommentsService struct {
// contains filtered or unexported fields
}
func (*CommentsService) Delete ¶
func (s *CommentsService) Delete(mediaId, commentId string) error
func (*CommentsService) MediaComments ¶
func (s *CommentsService) MediaComments(mediaId string) ([]Comment, error)
type ErrorResponse ¶
type ErrorResponse Response
ErrorResponse represents a Response which contains an error
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type GeographiesService ¶
type GeographiesService struct {
// contains filtered or unexported fields
}
func (*GeographiesService) RecentMedia ¶
func (s *GeographiesService) RecentMedia(geoId string, opt *Parameters) ([]Media, *ResponsePagination, error)
type Location ¶
type Location struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Latitude float64 `json:"latitude,omitempty"` Longitude float64 `json:"longitude,omitempty"` }
Location represents information about a location.
type LocationsService ¶
type LocationsService struct {
// contains filtered or unexported fields
}
func (*LocationsService) RecentMedia ¶
func (s *LocationsService) RecentMedia(locationId string, opt *Parameters) ([]Media, *ResponsePagination, error)
func (*LocationsService) Search ¶
func (s *LocationsService) Search(lat, lng float64, opt *Parameters) ([]Location, error)
type Media ¶
type Media struct { Type string `json:"type,omitempty"` UsersInPhoto []*UserInPhoto `json:"users_in_photo,omitempty"` Filter string `json:"filter,omitempty"` Tags []string `json:"tags,omitempty"` Comments *MediaComments `json:"comments,omitempty"` Caption *MediaCaption `json:"caption,omitempty"` Likes *MediaLikes `json:"likes,omitempty"` Link string `json:"link,omitempty"` User *User `json:"user,omitempty"` UserHasLiked bool `json:"user_has_liked,omitempty"` CreatedTime int64 `json:"created_time,string,omitempty"` Images *MediaImages `json:"images,omitempty"` Videos *MediaVideos `json:"videos,omitempty"` ID string `json:"id,omitempty"` Location *MediaLocation `json:"location,omitempty"` }
type MediaCaption ¶
type MediaComments ¶
type MediaImage ¶
type MediaImages ¶
type MediaImages struct { LowResolution *MediaImage `json:"low_resolution,omitempty"` Thumbnail *MediaImage `json:"thumbnail,omitempty"` StandardResolution *MediaImage `json:"standard_resolution,omitempty"` }
type MediaLikes ¶
type MediaLocation ¶
type MediaService ¶
type MediaService struct {
// contains filtered or unexported fields
}
func (*MediaService) Popular ¶
func (s *MediaService) Popular() ([]Media, *ResponsePagination, error)
func (*MediaService) Search ¶
func (s *MediaService) Search(opt *Parameters) ([]Media, *ResponsePagination, error)
type MediaVideo ¶
type MediaVideos ¶
type MediaVideos struct { LowResolution *MediaVideo `json:"low_resolution,omitempty"` StandardResolution *MediaVideo `json:"standard_resolution,omitempty"` }
type Parameters ¶
type Parameters struct { Count uint64 MinID string MaxID string MinTimestamp int64 MaxTimestamp int64 Lat float64 Lng float64 Distance float64 }
Parameters specifies the optional parameters to various service's methods.
type Ratelimit ¶
type Ratelimit struct { // Total number of possible calls per hour Limit int // How many calls are left for this particular token or client ID Remaining int }
Ratelimit specifies API calls limit found in HTTP headers.
type Relationship ¶
type RelationshipsService ¶
type RelationshipsService struct {
// contains filtered or unexported fields
}
func (*RelationshipsService) Approve ¶
func (s *RelationshipsService) Approve(userId string) (*Relationship, error)
func (*RelationshipsService) Block ¶
func (s *RelationshipsService) Block(userId string) (*Relationship, error)
func (*RelationshipsService) Deny ¶
func (s *RelationshipsService) Deny(userId string) (*Relationship, error)
func (*RelationshipsService) Follow ¶
func (s *RelationshipsService) Follow(userId string) (*Relationship, error)
func (*RelationshipsService) FollowedBy ¶
func (s *RelationshipsService) FollowedBy(userId string) ([]User, *ResponsePagination, error)
func (*RelationshipsService) Follows ¶
func (s *RelationshipsService) Follows(userId string) ([]User, *ResponsePagination, error)
func (*RelationshipsService) Relationship ¶
func (s *RelationshipsService) Relationship(userId string) (*Relationship, error)
func (*RelationshipsService) RequestedBy ¶
func (s *RelationshipsService) RequestedBy() ([]User, *ResponsePagination, error)
func (*RelationshipsService) Unblock ¶
func (s *RelationshipsService) Unblock(userId string) (*Relationship, error)
func (*RelationshipsService) Unfollow ¶
func (s *RelationshipsService) Unfollow(userId string) (*Relationship, error)
type Response ¶
type Response struct { Response *http.Response // HTTP response Meta *ResponseMeta `json:"meta,omitempty"` Data interface{} `json:"data,omitempty"` Pagination *ResponsePagination `json:"pagination,omitempty"` }
Response specifies Instagram's response structure.
Instagram's envelope structure spec: http://instagram.com/developer/endpoints/#structure
func (*Response) GetData ¶
func (r *Response) GetData() interface{}
GetData gets the meat of the response.
func (*Response) GetMeta ¶
func (r *Response) GetMeta() *ResponseMeta
GetMeta gets extra information about the response. If all goes well, only Code key with value 200 is returned. If something goes wrong, ErrorType and ErrorMessage keys are present.
func (*Response) GetPagination ¶
func (r *Response) GetPagination() *ResponsePagination
GetPagination gets pagination information.
func (*Response) GetRatelimit ¶
Parsed rate limit information from response headers.
type ResponseMeta ¶
type ResponseMeta struct { ErrorType string `json:"error_type,omitempty"` Code int `json:"code,omitempty"` ErrorMessage string `json:"error_message,omitempty"` }
ResponseMeta represents information about the response. If all goes well, only a Code key with value 200 will present. However, sometimes things go wrong, and in that case ErrorType and ErrorMessage are present.
type ResponsePagination ¶
type ResponsePagination struct { NextURL string `json:"next_url,omitempty"` NextMaxID string `json:"next_max_id,omitempty"` }
ResponsePagination represents information to get access to more data in any request for sequential data.
type User ¶
type User struct { ID string `json:"id,omitempty"` Username string `json:"username,omitempty"` FullName string `json:"full_name,omitempty"` ProfilePicture string `json:"profile_picture,omitempty"` Bio string `json:"bio,omitempty"` Website string `json:"website,omitempty"` Counts *UserCount `json:"counts,omitempty"` }
type UserInPhoto ¶
type UserInPhoto struct { User *User `json:"user,omitempty"` Position *UserInPhotoPosition `json:"position,omitempty"` }
type UserInPhotoPosition ¶
type UserInPhotoPosition struct {
// contains filtered or unexported fields
}
type UsersService ¶
type UsersService struct {
// contains filtered or unexported fields
}
func (*UsersService) LikedMedia ¶
func (s *UsersService) LikedMedia(opt *Parameters) ([]Media, *ResponsePagination, error)
func (*UsersService) MediaFeed ¶
func (s *UsersService) MediaFeed(opt *Parameters) ([]Media, *ResponsePagination, error)
func (*UsersService) RecentMedia ¶
func (s *UsersService) RecentMedia(userId string, opt *Parameters) ([]Media, *ResponsePagination, error)
func (*UsersService) Search ¶
func (s *UsersService) Search(q string, opt *Parameters) ([]User, *ResponsePagination, error)