{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Edge/API Management /
avatar image
2
Question by sgilson · Nov 23, 2015 at 02:32 PM · 1.1k Views analyticsapistats

How do you pass a time range to a stats API?

The SmartDocs page for the "Retrieve and Filter Metrics for a Dimension", says to pass a timeRange as:

MM/DD/YYYY HH:MM~MM/DD/YYYY HH:MM. 

For example:

8/24/2015 1200:00~9/20/2015 1200:00 

That works fine in SmartDocs because it URL encodes the time range in the generated curl command:

curl -X GET "https://api.enterprise.apigee.com/v1/organizations/sgilson/environments/test/stats/apis?select=sum(message_count)&timeRange=8%2F24%2F2015%201200%3A00~9%2F20%2F2015%201200%3A00&timeUnit=day" 

But in a straight curl command, how do you specify the time range? The doc says specify the date as MM/DD/YYYY%HH:MM using a % to precede HH:MM, as in:

curl  https://api.enterprise.apigee.com/v1/o/{org_name}/environments/test/stats/target_url?"select=sum(is_error)&timeRange=8/08/2015%1200:00~9/15/2015%1200:00&timeUnit=week" 

But that generates an error:

{
  "code" : "Invalid parameter - timeRange",
  "message" : "Invalid parameter - timeRange",
  "contexts" : [ ]
} 

If I do it like SmartDocs, by omitting the %, then I get no response at all:

curl  https://api.enterprise.apigee.com/v1/o/{org_name}/environments/test/stats/target_url?"select=sum(is_error)&timeRange=8/08/2015 1200:00~9/15/2015 1200:00&timeUnit=week" 

How do I pass the range then in curl?

Thanks,

Stephen

Comment
Add comment
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Close

2 Answers

  • Sort: 
avatar image
1
Best Answer

Answer by Anil Sagar @ Google   · Nov 23, 2015 at 02:36 PM

Hi @sgilson ,

Below curl command works for me,

curl -X GET -H "Authorization: Basic XXXXXXXXXX" -H "Cache-Control: no-cache" -H "Postman-Token: 9be9d357-c446-b438-f60f-06067e4667bc" 'https://api.enterprise.apigee.com/v1/o/ORG/environments/test/stats/apis?select=sum(message_count)&timeRange=08/15/2015%2000:00~11/01/2015%2000:00&timeUnit=month'

In MM/DD/YYYY%20HH:MM using a %20 to precede HH:MM

Comment
Add comment Show 2 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sgilson ♦♦ · Nov 23, 2015 at 02:57 PM 0
Link

Thanks @Anil Sagar. I'll update the doc to say that you have to precede HH:MM with %20.

Stephen

avatar image Anil Sagar @ Google ♦♦ sgilson ♦♦   · Nov 23, 2015 at 02:58 PM 0
Link

Anytime @sgilson :) , Glad query is resolved.

avatar image
2

Answer by Marc Schreuder · Nov 23, 2015 at 04:48 PM

@Stephen Gilson late to the party, just wanted to share that it also works if you use a "+" between the date and time, e.g.:

curl -v 'https://api.enterprise.apigee.com/v1/o/{orgname}/environments/{envname}/stats/apis?select=sum(message_count),sum(error_count)&sort=DESC&sortby=sum(message_count),sum(error_count)&t=agg_api&timeRange=11/11/2015+12:20~11/11/2015+12:25&timeUnit=minute&tsAscending=true&limit=5'
Comment
Add comment · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

30 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

analytics api 1 Answer

External Authorization - Analytics Feature - Apigee Edge 1 Answer

Would like to know list of apis,products and applications from Apigee of a particular organization. 2 Answers

Developer Registrations Over Time Report 3 Answers

How to determine what protocol is being used by the clients while connecting to Edge ? 3 Answers

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges